How To Link DevIL Linker Libraries Properly? - c++

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.

Related

"Undefined reference to _imp__" with MinGW on Eclipse

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.

Xcode linking against static and dynamic library

I have some problems with linking my macOS app against C libraries.
I have several question related to this issue.
It is better to link app against dynamic or static libraries taking into account that this will be very custom libraries rather not shared with other apps?
I have linked my macOS Xcode app against ~14 static libraries .a and it works fine. I have reconfigured CMakeLists.txt making this libraries and now Xcode project doesn't work. The main change was changing the directory I have
"$(SRCROOT)/../../c/<project_name>/outputs/lib/apple/static"
But now I have both static (.a) and dynamic (.dylib) libraries in the same path
"$(SRCROOT)/../../c/server/outputs/lib/apple"
I don't know whether this should matter, but linking against static libraries causes that after running my Xcode project it complains that it cannot load lib.dylib So maybe it finds this dynamic library under Library Search Paths and tires to load them but don't find them linked?
So I tired to link Xcode macOS app against .dylib libraries and instead of static .a libraries added them in Link Binary with Libraries. The problem is that the error not finding library now also occurs.
Maybe I should change something here ? But what If I will distribute my app to some other computers that will not have libraries in this specific location. How can I include dynamic libraries in Xcode bundle in order to be always findable.
I know I added maybe to many question. But would like to know how to the best solve this issue? Better to link statically or dynamically and then how to correctly achieve this avoiding this error.
UPDATE
It seems that when linking against .dylib it only works when I add path to this library directory to Runpath Search Paths.
It also seems that when I link against static library .a it works when .dylib isn't in the same directory (I moved .a library into /static subdirectory) and then for this moved library error isn't showing any more. But isn't there way to link statically when there is .a and .dylib libraries inside the same directory?
I know this is an old question but it's one of the top results when searching google for "Xcode static linking."
I recently encountered this issue when integrating with Intel IPP, which puts static and dynamic libs in the same directory.
If I used the standard Xcode linking method of adding the library via the "Build Phases | Link Binary with Libraries," Xcode translated that UI into a command line that looked like this:
clang++ ... -L/my/path -lstatic1 -lstatic2 ...
But that causes the linker to prefer the DLL instead of the static library in the same directory.
I worked around this by removing the entries from the "Build Phases | Link Binary with Libraries" window, and adding full relative paths to the libraries in the "Build Settings | Other linker flags" entry:
../../path/to/lib/libstatic1.a ../../path/to/lib/libstatic2.a
This caused Xcode to translate the UI into a command line that looked like this:
clang++ ... ../../path/to/lib/libstatic1.a ../../path/to/lib/libstatic1.a ...
Which linked the libraries statically.
Finally, I have linked this Xcode macOS project with multiple dynamic C libraries (.dylib).
REMARK
In order to link with static libraries (.a) They cannot be placed side by side with dynamic libraries! path/project_name/outputs/lib/apple/*.dylib and then place static libs under path: path/project_name/outputs/lib/apple/static/.a As XCode tries to link dynamic libraries if they found them on Libraries Search Path in Build Settings.
DYNAMIC C LIBRARIES LINKIN IN XCODE
Add dynamic libraries to Build Phases tab and Link Binaries with Libraries section as on the image
Embed all this dynamic libraries in output macOS Application Wrapper
You get something like this:
Then in Build setting add Libraries Search Paths
And finally add Runtime Search Paths in Build Settings

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.

Error building Static Library with OpenCV and Xcode on C++

I'm trying to build a DLL library for Unity3D (in 32-bit) but first of all I want to make a .a static library to make a C++ Wrapper for C#.
Well, this is what I've done.
I've built OpenCV unchecking BUILD_SHARED_LIBS in order to get the STATIC LIBS, with architecture i386.
I've made my static library code and built it, Linking the static libraries that I needed (I really import them all because I'm having errors and I want to know if it's an error lib-based):
(included from /lib/ and /3rdparty/lib/)
I'm linking my library and header in a new project (Command Line Tool) in order to test my new static library, but my errors are:
(pastebin link)
Well, I have no idea what's wrong.
This is my settings on the static library:
This is my settings on my test Command Line Tool (for testing my library)
Does anyone have idea about this?
Thank you very much in advance.
Regards.
EDIT: tried to manipulate the static libraries for 64 bits as well but nothing happened.
The solution was removing several paths on the Library paths since it was messing up some libraries.

Linker can't find lib in Eclipse/JNI/ANT

I am trying to build a large Java/c++ project involving JNI and ANT in Eclipse, under Linux. One of the source c++ files calls the log10() function for mathematical calculations. The project compiles fine, but fails at linking, where it complains that it cannot find the libm.so library necessary to link log10().
My problem is that I am unable to properly tell Eclipse to link that file, even after the following steps:
Added the correct library path in the linker options,
Added a reference to libm in the linker include list,
Added -lm to the full compile options list,
Set LD_LIBRARY_PATH to point to the library's location,
Copied the library to the current directory.
What am I doing wrong/has anyone had such experiences with correctly linking libs in Eclipse? Any suggestions?
This is a bit confusing.
If you fail to find your library at runtime inside your java environment :
Try loading your .so library inside the java environment before making any calls to log10.
System.LoadLibrary("m");
Notice how I left "lib" and ".so" out.
However, you are complaining of a Linker problem from C++, you cannot link to a dynamic file. You can only link to a static library, or a static export library (so you need a libm.a file to which to link at compile time, and then your program will require libm.so at runtime).
Could you post the exact message you are receiving and when you are receiving it ?