0

I am getting the error

C:/msys

64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\204035~1\AppData\Local\Temp\ccfgNT9U.o:wave_capture.c: (.text$_ZN5boost4asio6detail17winsock_init_base7startupERNS2_4dataEhh [_ZN5boost4asio6detail17winsock_init_base7startupERNS2_4dataEhh]+0x74): undefined reference to `__imp_WSAStartup'

Along with

undefined reference to __imp_WSACleanup'

undefined reference to __imp_WSASetLastError'

undefined reference to __imp_WSAGetLastError'

undefined reference to __imp_WSAStringToAddressA'

And one other related to a .h, .lib, and .dll located in the same folder as the .cpp file.

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\204035~1\AppData\Local\Temp\ccfgNT9U.o:wave_capture.c:(.text+0x33b): undefined reference to `TmcInitialize'

Am I missing something in tasks or other files?

tasks.json

{
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "C:\\msys64\\mingw64\\bin\\g++.exe",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
            "cwd": "C:\\msys64\\mingw64\\bin"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": "build",
        "detail": "Task generated by Debugger."
    },
    {
        "type": "cppbuild",
        "label": "C/C++: gcc.exe build active file",
        "command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
            "cwd": "C:\\msys64\\mingw64\\bin"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": "build",
        "detail": "Task generated by Debugger."
    }
],
"version": "2.0.0"

}

I have also tried with mixed luck

            "command": "C:\\msys64\\mingw64\\bin\\g++.exe -lprocess -laddress -ltmctl64 -lrt",

Using Mysys, I should not have to edit my tasks and configuration json files to include boost and tmctl, according to a comment made in this thread.

note: I have read many 'undefined reference' threads here and tried a few changes, but without luck.

yelkenli
  • 1
  • 1
  • The WSA... errors are due to the winsock library. I don't see any evidence that you are linking with it. Do you think that you are? – john Oct 31 '22 at 13:14
  • The functions are from the Windows runtime. Have you linked it? – VLL Oct 31 '22 at 13:14
  • Your `tasks.json` needs to link to the `Ws2_32` library. It looks like you have not edited this file to link to the additional library. – drescherjm Oct 31 '22 at 13:30
  • I am sorry if I misled you in the previous question. While you don't have to edit the `tasks.json` to add the include directory or library path for linking of third party libraries when using msys2 you do still have to link to dependent libraries in the `tasks.json` using `-llibname`. In the case of `boost` many of the libraries are header only however some are not and require linkinng. – drescherjm Oct 31 '22 at 14:39
  • thanks for the input. I am unable to find any example similar to mine to follow along, or tutorial on where to link and with what words. I have read a lot about hello world and then some C compiler pages that do not relate to any of the above (though it is probably correct and basic information). Any recommended reading is appreciated. – yelkenli Nov 01 '22 at 18:42

0 Answers0