Using visual studio 2008, I have an .H and a .LIB file of a library.
I wrote a program and referenced the LIB via the project properties.
It compiles fine, but when it runs, it asks for the DLL to be installed.
If the DLL is in the same dir as the EXE it works but, if I have the LIB, doesn't it already mean the functions are statically linked to my program?
Not all lib files are static libraries. Some are import libraries, and chances are, that's what you linked with.
If your lib file is much smaller than its corresponding dll file, that's a sure sign that it's an import library.
Letting your program use a DLL requires an import library. It is a file with the .lib extension, just like a static .lib. But it is very small, it only contains a list of the functions that are exported by the DLL. The linker needs this so it can embed the name of the DLL in the import table. You can see this for yourself by running Dumpbin.exe /imports on your .exe
Related
How can I build a standalone static library (.a) for a firmware module and link that static library in the main project (without providing access to header files in that module) ?
I know about ar command but that is just compiling the .c files, when I try to use the functions in one of the .c files of the firmware module it shows me implicit function deceleration warning. I do not want to export the .h files but rather just provide a libexample.a package to the developer to use the firmware module.
Will the pre-compiled header work in this scenario?
I've got two projects in solution, library and executable.
First I build library but then when I start build another project it cleans library even when library files is in different folder and should not anyhow conflict with it.
How to say to not remove library by building my executable?
If your executable depends on your library, the library will be automatically cleaned when cleaning or regenerating the executable.
It will not be cleaned if only generating the executable (not regenerating), which will only compile modifications since the last build.
If your executable does not depend on your library, the library should not be cleaned.
If this is really the case, you can try to build the executable by right clicking on the project located in the solution explorer.
I compiled a C project using the NDK and got many .a files which as I understand, they are nothing else than static libraries. I don't know exactly what is the difference between .a and .so files but I wanted to ask: I know exactly that with a toolchain in NDK I can import all the .a files and get the .so file but having the .a files how to include the .a files in the .interface files to SWIG the whole library ?
SWIG does not generate interface files from libraries. You can provide a wrapper to include all relevant header (.h) files, or create the .i file manually, only exposing the relevant C functions.
Note that Android app cannot work with static libraries, you must build a dynamic library .so to use JNI. You will call System.load() from your Java code to load this .so from disk.
Hi All
I wrote a static library (libA) that uses another library (libB).
How can I link libB to my libA in eclipse (linux)? i cannot find linkage options in project properties, they are not on there usual place.
Thx
Static libraries don't link. They are an archive of object files (.o files). These archives are then taken as arguments during a linking phase, have their object files extracted and linked into the application at that time. As such, static libraries cannot link against anything.
I wanted to learn how to use a .lib file in my C application.
So, I followed these steps:
Created a empty project in VC++,
Added a .c file,
Added few c functions,
Created a .h file for the same,
Changed the projects type to .lib
Built the project.
No problem till here.
Now,
I copied the .h and the .lib file to desktop,
created another VC++ empty project of type .exe,
In poject prop.->config. prop.->c/c++->additional include directories,I added the path to desktop,
In poject prop.->config. prop.->linker->additional library dependencies,I added the path to desktop,
building the project gives LNK2019 (unresolved external symbol _...) and fatal error LNK1120 (unresolved external symbols).
What am I doing wrong? Also what would be the steps to use a .dll instead of .lib?
Configuration: Windows 7, VS2008.
You also have to add the library by name to the list of Additional Dependencies in Linker->Input options for your Project.
Do you really want this linked in from the desktop, by the way? Typically some project-relative path or environment variable would be the way to do this - you do not want to link from desktop on a build server, for example.
Switching to a DLL will not help because you still need to use the export library (.LIB) file for your DLL to satisfy the link-time dependencies.