fpagliughi / sockpp

Modern C++ socket library.
BSD 3-Clause "New" or "Revised" License
769 stars 126 forks source link

Error LNK2019 #70

Closed Frp529 closed 1 year ago

Frp529 commented 1 year ago

Hi guys,

I created a C++ project with VS 2019 and related head files and a library are added to the project. Unfortunately, it is unable to build successfully. Are there some critical steps I've overlooked?

1667915884206

fpagliughi commented 1 year ago

Apologies, I don't know Windows very well. It seems like it says that it's linking to the sockpp library, but the errors make it seem like it's not.

I just released an update (v0.8.0) with a bunch of changes to the CMake files. I wonder if anything in there helps, or if not just changes the result.

Can you give it a try with the latest version?

Either way, there's a number of outstanding issues with the Windows build, so I will try to get them fixed shortly.

fpagliughi commented 1 year ago

I just tried it with the latest release, v0.8.0, and got some unresolved symbols from the linker, but they appeared to be the system calls.

I manually had to add the library dependency: ws2_32.lib

Once I did, it built and ran fine. Let me know if that helps. (Perhaps the transitive dependency in CMake doesn't work for static libs in Windows?)

Also... if you build the library with CMake on Windows, it creates a sockpp.sln with project files like sockpp-static.vcxproj. It seems like you can just add those to your project, if you keep them on your machine. But it seems like you still need to add ws2_32.lib to your app project.

fpagliughi commented 1 year ago

Also note that the DLL now seems to build properly on Windows with v0.8.0... and the DLL appears to link in the required system libraries. So you can give that a try as well.

Build sockpp with -DSOCKPP_BUILD_SHARED=ON (which is now the default), then link your app to sockpp.lib and make sure sockpp.dll is in the path.

fpagliughi commented 1 year ago

I'm hoping the fix for #38 (f263fb70458d9da3cab9385a6fc3502982d6f985) also fixed this. If not, please let me know.

fpagliughi commented 1 year ago

I hope this is fixed by the updated CMake build in v0.8.1. If not please re-open this issue with any new information.