"Undefined reference to _imp__" with MinGW on Eclipse - c++

I'm trying to build a third-party C++ code on Eclipse but I get some errors at the linking level. In particular, it seems that I can't link against the import libraries that I'm in possession (the ones with .lib extension), as you can see from the messages in the build log:
build log
I believe I set the path to the libraries correctly and maybe you can confirm this:
libraries' paths
The linker is able to find those libraries (in this case xsensdeviceapi64.lib and xstypes64.lib), so I donĀ“t understand the origin of these errors. Any ideas on how to solve this issue?
Thanks.

Related

Why can't I link this library using the GNU GCC Compiler on Windows (but on Linux I can)

I've been trying to link this CryptoPP library for some time now; no luck. Due to most of the resources relating to linking the CryptoPP library being on the Linux platform I temporarily installed Ubuntu on a VM and got CryptoPP working quite smoothly, however, as previously mentioned, it doesn't work on Windows.
I am using the CodeBlocks IDE on Windows 8 using the MinGW compiler.
I already have the static CryptoPP .a file built.
My 2 attempts at linking the CrypoPP library have been:
A:
- Add the locations of the header files to the compiler and linker search directories (so it doesn't give me those "Head not found" errors)
Add the library to the Link Libraries section (I added "libcryptopp")
I know that the compiler can see the Linked Library because when I change the name to the libcryptopp.a file to something else (libcryptopp1.a) it says "-llibcryptopp not found"
In the end I get a whole bunch of Undefined API error messages :(
B: I then tried to add the header and library files to my compiler directory in suspicion of my IDE's search directory somehow failing me, this was not the case; I received the same Undefined API error messages.
I am tired of fighting this, if anyone could please leave some tips or point something out that I'm doing wrong I would be very grateful.

OpenGL codeblocks compilation issue win7 [duplicate]

I'm using the <XZY> IDE to compile my program, and have some trouble to import/integrate a specific library with it.
I get error messages like
fatal error: 3rdPartyLib.h: No such file or directory
for a
#include "3rdPartyLib.h"
statement
ld.exe: cannot find `lib3rdParty.a`
for specifying
3rdParty
in the additional libraries
At least I got some error message like
undefined reference to `lib3rdParty::foo()'
What can I do to fix this?
It's a common misconception, that the current IDE used, is responsible for getting errors like stated in the question.
See for example
c++ lib in two same project ,one can work but the other can 't
Issue linking libxml++ and glib libraries with CodeBlocks IDE for C++ Windows
...
The problem is almost never related to the currently used IDE.
In the most cases the solution boils down, to supply the actual toolchain's compiler/linker with the appropriate path's to search for included headers, to be linked libraries.
One of the major applicable answers for the linker related problems are
What is an undefined reference/unresolved external symbol error and how do I fix it?
undefined reference to `WinMain#16'
Most of the common IDEs provide features to configure this for a specific project. Here are some samples
Eclipse-CDT
Include path settings:
Library & library search path settings
Visual Studio 2013
Code Blocks
**DEV C++ (Bloodshed C++)
As from their FAQ:
9. How can i use the OpenGL library and others ?
All the libraries that comes with Mingw reside in the Lib directory. They are all named in the following way: lib*.a
To link a library with your project, just add in Project options, Further option files :
-lopengl32
This is for including the libopengl32.a library. To add any other library, just follow the same syntax:
Type -l (L in lowercase) plus the base name of the library (filename without lib and the .a extension).
You may also consider putting a -L option there to add directory pathes searched for libraries.
Qt Creator
In order to add include paths you have to open up the .pro file and then add
the directories to the INCLUDEPATH variable. These paths are separated by spaces. Reference can be found here.
If none of the above samples applies for your actually used IDE/toolchain, I hope you're able to get the point of abstraction:
It's an issue how to provide compiling/linking options to your actual toolchain. The IDE used to setup the context is a minor point here.
For eclipse I use the pkg-config plugin where possible:
https://marketplace.eclipse.org/content/pkg-config-support-eclipse-cdt
Failing that this configuration window:

How To Link DevIL Linker Libraries Properly?

Linking these libraries was just like linking any other library.
But my issue comes when I run my project I am not getting linker errrors but my error is about "DLL"
I get
"The program can't start because DevIL.dll is missing from your computer. Try reinstalling the program to fix this problem"
I do not want the .dll. I linked the other libraries for a reason.
Or am I assuming wrong and DevIL will only work by me having to place this DLL in the system root?
Because my goal is to link DevIL without putting any DLLs in other places. I just figured I could use the the linker libraries like how you can with openGL.
If there's any good example let me know. I have also done some tutorials and a few examples but no luck. I keep getting this "DevIL.dll is missing" error window.
AFAIK ,the DevIL distributions come with import libs only.What you are talking about is called static library which is compiled into your executable and therefore doesn't require DLL.I tried to search for static libs of DevIL but didn't find.So you have to build DevIL from sources to compile static version by yourself.

Problems importing libraries to my c++ project, how to fix this?

I'm using the <XZY> IDE to compile my program, and have some trouble to import/integrate a specific library with it.
I get error messages like
fatal error: 3rdPartyLib.h: No such file or directory
for a
#include "3rdPartyLib.h"
statement
ld.exe: cannot find `lib3rdParty.a`
for specifying
3rdParty
in the additional libraries
At least I got some error message like
undefined reference to `lib3rdParty::foo()'
What can I do to fix this?
It's a common misconception, that the current IDE used, is responsible for getting errors like stated in the question.
See for example
c++ lib in two same project ,one can work but the other can 't
Issue linking libxml++ and glib libraries with CodeBlocks IDE for C++ Windows
...
The problem is almost never related to the currently used IDE.
In the most cases the solution boils down, to supply the actual toolchain's compiler/linker with the appropriate path's to search for included headers, to be linked libraries.
One of the major applicable answers for the linker related problems are
What is an undefined reference/unresolved external symbol error and how do I fix it?
undefined reference to `WinMain#16'
Most of the common IDEs provide features to configure this for a specific project. Here are some samples
Eclipse-CDT
Include path settings:
Library & library search path settings
Visual Studio 2013
Code Blocks
**DEV C++ (Bloodshed C++)
As from their FAQ:
9. How can i use the OpenGL library and others ?
All the libraries that comes with Mingw reside in the Lib directory. They are all named in the following way: lib*.a
To link a library with your project, just add in Project options, Further option files :
-lopengl32
This is for including the libopengl32.a library. To add any other library, just follow the same syntax:
Type -l (L in lowercase) plus the base name of the library (filename without lib and the .a extension).
You may also consider putting a -L option there to add directory pathes searched for libraries.
Qt Creator
In order to add include paths you have to open up the .pro file and then add
the directories to the INCLUDEPATH variable. These paths are separated by spaces. Reference can be found here.
If none of the above samples applies for your actually used IDE/toolchain, I hope you're able to get the point of abstraction:
It's an issue how to provide compiling/linking options to your actual toolchain. The IDE used to setup the context is a minor point here.
For eclipse I use the pkg-config plugin where possible:
https://marketplace.eclipse.org/content/pkg-config-support-eclipse-cdt
Failing that this configuration window:

Undefined reference to Eclipse C++

I've tried more and more time, but I got the same error.
When I use an external lib, for example I'm try to work on openssl and crypto++, I receive the error: "undefined reference to (function)".
I dunno why Eclipse do that neverthless the #include are all correct.
I've tried even to add the path from Properties-C/C++ General-Path & Symbols but nothing.
Can anybody help me?
You must specify the name of the shared libraries which must be linked to the executable.
Assuming you are using the GNU toolchain, you can do it by following these steps:
Right-click on the project, then select Properties
Go under C/C++ Build -> Settings
Select GCC C Linker -> Libraries
In Libraries (-l), add the name of your libraries,
If needed, put the directory where your libraries are hosted in Library search path (-L).
I have the same problem too. I was using Eclipse CDT and trying to build my source code with OpenSSL headers and I got the same "undefined reference" problem.
To those who may be also suffering from this type of errors, try these steps:
Make sure you use the right compiler(for Ubuntu 18.04)
right click your project->preference->C/C++ Build->tool chain editor->use CDT internal Builder / Linux gcc(you can try to run HelloWorld as a test)
C/C++ Build->settings->gcc linker, see right there is a "+", click and type ssl and crypto
Rebuild your project, done.
I strongly recommend you to learn gcc compiler command line. If you have compile problem, always use the terminal and command line to see if you can compile it successfully, then compare the succeeded command with the console log in Eclipse, at where you can see the actual gcc command that used to compile your code.
A good resource for gcc command: https://www.rapidtables.com/code/linux/gcc/gcc-l.html