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

Set propper runtime library for use in msvc project #1079

Closed
Chrys4lisfag opened this issue Jul 7, 2024 · 5 comments
Closed

Set propper runtime library for use in msvc project #1079

Chrys4lisfag opened this issue Jul 7, 2024 · 5 comments

Comments

@Chrys4lisfag
Copy link

Description

Tried to build as static library for use in msvc project and got runtime mismatch with my library and cpr.
cpr had /md while I needed /mt

Example/How to Reproduce

  1. Build with -DBUILD_SHARED_LIBS=OFF
  2. Try to use in msvc project with /mt flag

Possible Fix

Adding this resolved the issue
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$CONFIG:Debug:Debug>")

Where did you get it from?

GitHub (branch e.g. master)

Additional Context/Your Environment

I am new to cmake but as I understand this must be accounted on your side

@COM8
Copy link
Member

COM8 commented Jul 10, 2024

@Chrys4lisfag thanks for reporting. I'm not a Windows dev working with msvc so my knowledge here is limited.
Here is a full example for using cpr in CMake even on Windows: https://github.com/libcpr/example-cmake-fetch-content

This can be taken as starting point.

@COM8 COM8 self-assigned this Jul 10, 2024
@Chrys4lisfag
Copy link
Author

@Chrys4lisfag thanks for reporting. I'm not a Windows dev working with msvc so my knowledge here is limited. Here is a full example for using cpr in CMake even on Windows: https://github.com/libcpr/example-cmake-fetch-content

This can be taken as starting point.

Yeah, I've got no issues with cmake project. The only issue when I've build cpr as static library and tried to link it to my msvc project. It had crt linking type mismatch between cpr.lib and my msvc project, so I had to modify cpr library CmakeLists by adding "set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$CONFIG:Debug:Debug>")" this line to make it work.

@kevinmoloney7
Copy link

@Chrys4lisfag How did you add this I am facing the same issue. I am using cmake fetch content to include cpr in my project. Where did you include set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$CONFIG:Debug:Debug>

@Chrys4lisfag
Copy link
Author

@Chrys4lisfag How did you add this I am facing the same issue. I am using cmake fetch content to include cpr in my project. Where did you include set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$CONFIG:Debug:Debug>

I've added this directly in the cpr`s CMakeLists then built cpr library as static (-DBUILD_SHARED_LIBS=OFF) and used output .lib and includes in my project

@COM8
Copy link
Member

COM8 commented Jul 21, 2024

Closing this one as there seams no action required from the cpr side here.

@COM8 COM8 closed this as completed Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants