question

viseg-3942 avatar image
0 Votes"
viseg-3942 asked AnnaXiu-MSFT edited

Lost symbols in static library

Hi,
I am trying to store a text file as a resource for a library I am building using this tool :
https://github.com/vector-of-bool/cmrc/tree/2.0.1

It works out fine as I compile + execute my program. But when I try to create a static lib from it, the tool's source code isn't linked into my generated .lib file so I cannot access it afterwards (from an outside program, linking with my lib). I am compiling using MSVC (Visual Studio 16)

The final goal is for my program to be linked by a DLL, with the text file included inside of it, as part of the library, so that I don't have to provide/copy additional files with the library. My goal is pretty similar to what is asked inside this post https://stackoverflow.com/questions/8248731/embedding-opencl-code-into-executable ; except I don't want to have clear code directly available in my .lib file.

windows-10-application-compatibilitywindows-embedded
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hi there,

To make your program linked to a DLL you can use implicit linking or explicit linking. Whether to use implicit linking or explicit linking is an architectural decision you must make for your application. There are advantages and disadvantages to each method.

Here is a link for a detailed description of the process that you must follow. Link an executable to a DLL https://docs.microsoft.com/en-us/cpp/build/linking-an-executable-to-a-dll?view=msvc-170

Also note that you can't statically link a DLL, only a LIB. DLLs are self-contained and have static members and DllMain load/unload dependencies which means they cannot be split into containing functions and linked into a different executable.



--If the reply is helpful, please Upvote and Accept it as an answer–

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.