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 an external library.
Simple programs compile and link fine, but when I try to add SQL funcionality with 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 Project Library Path. I specified C:\MinGW\lib\libodbc32.a as the one-and-only Project Library (this made the unresolved-reference errors go away in the IDE).
I switched to the CLI and pasted the compile command. For the library name, I've tried: odbc32, odbc32.a, libodbc32, libcodbc32.a I also tried: odbccp32, odbccp32.a, libodbccp32, libodbccp32.a I've used forward slashes, backslashes, double-backslashes, quotes around the path, quotes around the entire -l parameter (which is what Eclipse does to the -L parameter).
I copied the libraries into the directory containing the compiled code to eliminate the need to specify the path. I copied them into the directory containing ld.exe. I updated the Windows path to include the directory and restarted Eclipse and the CLI.
If I remove the -l parameter entirely, I get all kinds of unresolved-reference errors. It seems ld.exe is finding the library but is bent on hiding the real problem.
What is the secret to linking to the built-in SQL libraries?
Got it at last!
When using the CLI, don't include the path in the -l parameter, drop the ".a" suffix and the "lib" prefix:
-lodbc32
The path is supplied by the -L
parameter.
To make it work in Eclipse, edit the Library entry (Project Properties/Paths and Symbols/Libraries tab) after adding it. Remove the path, "lib", and ".a". (Eclipse will warn about the dangers of using relative paths.) Remember this step whenever you add an external library.
It now works fine in both Eclipse and the CLI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With