A easy build way for MS Visual Studio user #1780
-
My project use Windows VS compile, but I can't run it successful, I have try all ways below two issues, it's no useful. No matter use static lib or dynamic lib, complier gives me link error. But I have find another way, it can help me compile project easily, use vs generator in cmake. Compile in project: Then can run project easily. I have tried use build way in project index and compile, it no use. but I use cmake visual studio generator. I successful. I also notice that you seems do not use visual studio, I can give more details about how to compile |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Indeed I don't use Visual Studio. The requirement for NNG_STATIC_LIB depends on whether you want to use static libraries and linking or not. If you want to use dynamic linking on Windows its a bit more complicated. You have to build with NNG_SHARED_LIB when building the library itself (which should be done automatically), and then don't build with either NNG_STATIC_LIB or NNG_SHARED_LIB when you are building an application that should use the library. I should probably just look into building an import lib file for Windows. |
Beta Was this translation helpful? Give feedback.
-
I try the below commands
then I get the result in build\Release directory as below build\Release Mode LastWriteTime Length Name -a---- 2023/9/18 17:51 1621412 nng.lib so I wonder whether default output is static lib or dynamic lib ? by the way, I hope to use nng in C# project. |
Beta Was this translation helpful? Give feedback.
-
default output is a static lib, if you want to get a dynamic lib, maybe you should use -DBUILD_SHARED_LIBS=ON, more details in #1212 , But I haven't try this way |
Beta Was this translation helpful? Give feedback.
-
I know what you want to say, But if I do as index said, and then no matter the static lib or dynamic lib can't be linked correctly in Visual Studio. it need not to be built again, it just do link ,like this, 'gcc -L libpath -llibnng -I header_path' |
Beta Was this translation helpful? Give feedback.
-
The situation with static vs. dynamic libs on Windows is a bit annoying, for certain. CMake has not done much to make this easier. One possible problem is that the Visual Studio recipes might be getting this wrong. If you're building NNG itself, you should use NNG_SHARED_LIB, and then when you build calling library you don't need to do either. If you're using static libaries, just put NNG_STATIC_LIB in your cmake configuration. |
Beta Was this translation helpful? Give feedback.
-
Btw, we always build a static library for the test suites. |
Beta Was this translation helpful? Give feedback.
-
use vcpkg |
Beta Was this translation helpful? Give feedback.
use vcpkg