Skip to content
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

Static library linking example (Windows) #68

Open
dmitrystvorkin opened this issue Jan 4, 2022 · 1 comment
Open

Static library linking example (Windows) #68

dmitrystvorkin opened this issue Jan 4, 2022 · 1 comment

Comments

@dmitrystvorkin
Copy link

Hello, could you help please with an example/advice?

I have builded a project with VS2022 and get cppserver.lib file, but withour a header file, I can't use it in my own code. For example I want to connect this TCP server for MT5 dll plugin and use the cppserver.lib as static library.

Could you advice please, how to do it in better way?

@chronoxor
Copy link
Owner

You cannot use static cppserver.lib without headers. After you compile CppServer you need to add cppserver.lib to your project, and also add ..\CppServer\include path to Include Directories.

It is very easy to do if you have your own CMakeLists.txt. Just create CppServer.cmake:

if(NOT TARGET cppserver)

  # Module flag
  set(CPPSERVER_MODULE Y)

  # Module subdirectory
  add_subdirectory("CppServer")

  # Module folder
  set_target_properties(cppserver PROPERTIES FOLDER "modules/CppServer")

endif()

Include it into your CMakeLists.txt and link your target over cppserver:

include("..\your_path\CppServer.cmake")

target_link_libraries(myMT5plugin cppserver)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants