0
votes

I am building a cpp lib using cmake. x86_64 I want a SHARED lib, so I am using shared and everything is building fine without any errors but it is only creating the dll file. I am also using __declspec(dllexport), so there should be one

later on I want to link the lib with my test program but always get the error fatal error LNK1181: cannot open input file '..\lib\Release\MQTTClient.lib'

because vs is not creating any lib file ...

anyone an idea?

1
Usually that means you aren’t exporting any symbols but you said you’re using dllexport. Edit your question to show an example of how it’s used. - Khouri Giordano
Without passing your export flag, Visual Studio won't export symbols and so no library will be created. You can as a test, because it is ugly but sometimes needed, use CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=True It should export a .lib see cmake.org/cmake/help/v3.12/variable/… The first option, passing the Export flag is the best one (the default behaviour is dllimport if you don't precise.) - Noki
thx, the cmake flag was the solution - mojado
@Noki Please consider to transfer your comment into an answer, so mojado can accept it and mark this question solved. - Stanley F.
@Stanley Will be done ASAP - Noki

1 Answers

1
votes

You can use the CMake Flag :

CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=True

It should exports a .lib file, with every functions symbols in it.

see the official CMake Documentation for more details

This flag is pretty useful, especially when you have to deal with 3rd parties, you'll need to pass the flag to CMake when building for Windows.

But it's better to explicitly mark functions, that you want to exports with __declspec(dllexport). I really don't know what you did wrong

(Comment turned into an answer)