I'm working with visual studio,
and I have two different static libs which share the same .obj file, but that .obj file is newer in one of them.
I need both of these libs so i can't exclude one of them,
How can I "make" the linker to take this specific .obj file from the static lib I want him to?
It's either that or i will have to add the .obj file every time he has been changed, cause it's location is based on the version number while the lib file is in a global location.
Unless there's other solution.
Related
Is it possilble to link .so file into .a file
A 3rd party only offer a so
Our .a lib depend on it.
And we don't want to give customer too much dependency
No, you can't convert a shared lib back to a static lib. There is information in the .o files that gets discarded when they are welded together into a .so file. If you really want static linking, you'll have to persuade the third party to also ship you an archive.
What configuration do I need to give QMake to generate a vcxproj file where the object files are arranged in a tree like the original code?
I have been searching for quite a while and even scrutinized the source of qmake but to no avail.
So far I tried CONFIG -= flat which only changed the filters, but not the output paths. And object_parallel_to_source which only works with makefiles as far as I can tell.
I need the feature to avoid name clashes of object files having the same name, because their source files have the same name but reside in different folders.
It is definitely possible to avoid this with MSVC by setting the appropriate output path for files in their properties dialog. However, this is tedious and as I am developing a project mainly on Linux and then porting it over to Windows from time to time I have to do the whole procedure over and over again.
I have downloaded some dll files and with it came also pdb, exp and ilk files. Now I need to know do I need to put them in my system file, or not and what is the purpose of each of them in the general?
PDB files contain debug information and are useful if you need to step through the DLL's code at any point.
ILK files are used by the linker. They are not needed unless the DLL is to be recompiled.
EXP files contain information about things exported from the DLL
.ilk files are intermediary files created by the linker during the development cycle. .ilk files serve the purpose of incremental linking. If the linker does not find and .ilk file when trying to do incremental linking, then it will do a full linking and reproduce the .ilk file. Incremental linking is meant to speed up the linking process. You can safely delete .ilk files.
.exp files are for developers too. .exp files are created for .exe and .dll files that export some symbols. Their purpose is similar to .lib import libraries, but there is a subtle difference. .exp files are always created, even if the creation of the corresponding .exe or .dll fails at link time. By contrast, .lib import libraries are created only when the corresponding .exe or .dll linkage succeeds. .exp files help linking interdependent components. For example, an .exe might provide access to its common resources for its plugins by exporting some functions. The plugins also provide exports for the .exe to call. Interdependencies like this cannot be successfully linked. The .exe linkage will fail, because the import .lib for the .dll is missing. Consequently no .lib for the .exe will be created. The linkage of the .dll will fail because the import library for the .exe is missing. Export files however will be created even if linkage failed, so the .dll could link against the .exp file rather than the .lib file for successful linkage.
I want to try making a simple game engine. Just something that handles states, assets, characters/actors and their stats and an inventory. Most of the code I can take from other games I've wrote, but I'm confused on how I then turn it into a static library. Do I need a main.cpp? If so what has to go in it? Under Linux I'm guessing I compile it to .so and add the headers to my include directory and then just link to the .so but what do I do on Windows and Mac?
A .so is not a static library, it's a dynamic one. A static library is, in its most basic, a .o file compiled from a single C file, or a .a file which is simply a collection of .o files.
A static library is different from a shared one in that the object code is linked directly in to the final executable, requiring no dependencies at run time.
Under Unix, the ar(1) command is used to bundle .o files in to a composite .a file. I do not know the comparable utility for Windows.
Once you have the .a file, you will simply need the combination of the .a file and the .h files to build your code. You use the .h files for compiling, and then link against the .a file.
Shared libraries have a specific advantage over static libraries in that if you have multiple, yet different, programs relying on the same libraries, the code from the shared libraries can be shared among all of the programs at the same time, so in that sense they lower the overall impact on the system. Their downside is slower start up times (though that's pretty marginal nowadays). Statically linked libraries can not be shared across independent programs, but if you run the same executable several times, its code will be shared.
So I used the VisualMagick tool to set up a Static Library project and compiled all of the ImageMagick Source to static lib files. Then I created a new solution and moved all those libs and the needed .h files to my lib folder in my new solution. My cpp file that I want to use the lib files compiles fine, even with #include Magick++.h in the header, until I add any references to things in imageMagick. Like if I say Magick::Image image; It will give me LNK1120. I have added the lib folder to my projects Additional Library Locations (or something like that) in the solution properties. I am new to the whole Linking language thing, coming mostly from a Python/Java background. Any suggestions? I have tried a brute google search and tried a lot of the suggestions I have seen.
I'll put the foregoing comments interchange in the form of a real answer:
To convince VS20xx to link your app with some non-standard library, including maybe a new library that you just built:
Under the VS main-menu "Project" tab, take "<your-project-name> Properties ..." and then
First, tell the linker where to look for a lib (like make -L):
Linker --> General
In the "Additional Library Directories" edit box, give the paths -- just the directories -- where lib files live.
Second, tell the linker what library files you want to lilnk with (like make -l):
Linker --> Input and then
In the "Additional Dependencies" edit box, add the space-separated unadorned lib-file name(s), no quotes needed, like:
Additional Dependencies mysqlclient.lib libcurl.lib mynewlib.lib
That should be it. (yeah, suuuuuuuuure :-)