GCC / LD cannot find link library

OS: Windows 7 Enterprise x64 IDE: Eclipse Juno / CDT Compiler: MinGW 4.6.2 (C: \ MinGW)

Like user697111 , I cannot get ld.exe to find the external library.

Simple program compilation and communication is fine, but when I try to add SQL functionality to the supplied library, I get this error message in Eclipse: "c: / mingw / bin /../ lib / gcc / mingw32 / 4.6. 2 / .. /../../../mingw32/bin/ld.exe: Cannot find -lC: \ MinGW \ lib \ libodbc32.a ".

I specified C: \ MinGW \ lib as the path to the project library. I specified C: \ MinGW \ lib \ libodbc32.a as a single project library (this led to unresolved link errors disappearing in the IDE).

I switched to the CLI and inserted the compilation command. For the library name I tried: odbc32, odbc32.a, libodbc32, libcodbc32.a I also tried: odbccp32, odbccp32.a, libodbccp32, libodbccp32.a I used slashes, backslash, double backslash, quotes around the path, quotes around the entire -l option (which is what Eclipse does for the -L option).

I copied the libraries to a directory containing the compiled code to eliminate the need for a path. I copied them to the directory containing ld.exe. I updated the Windows path to include the directory and restarted Eclipse and the CLI.

If I completely remove the -l option, I get all kinds of unresolved link errors. Ld.exe seems to find the library, but tends to hide the real problem.

What is the secret of linking to built-in SQL libraries?

+4
source share
1 answer

Got it finally!

When using the CLI, do not include the path in the -l parameter, leave the suffix ".a" and the prefix "lib": -lodbc32 The path is provided by the -L parameter.

To make it work in Eclipse, edit the Library tab (Project Properties / Paths and Symbols / Libraries tab) after adding it. Delete the path "lib" and ".a". (Eclipse will warn you about the dangers of using relative paths.) Remember this step when you add an external library.

Now it works great in both Eclipse and the CLI.

+4
source

Source: https://habr.com/ru/post/1485500/


All Articles