-
-
Notifications
You must be signed in to change notification settings - Fork 470
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A easy build way for MS Visual Studio user #1690
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. |
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. |
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 |
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' |
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. |
Btw, we always build a static library for the test suites. |
use vcpkg |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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.
#1212 #550
But I have find another way, it can help me compile project easily, use vs generator in cmake.
Build Steps:
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 //just for vs2022
cmake --build . --config Release
MoreVisual Studio version details read this https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html#id14
Compile in project:
Add NNG_STATIC_LIB in Preprocessor #this is important, it's not so usual for vs user
Add include file path
Add lib file and file path in linker
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
The text was updated successfully, but these errors were encountered: