On windows you don’t link the shared object but the import library. That means you need to link to the associated “libabcd.lib”. The dll must be in your PATH (or one of the known directories) when you run your program then.
I left this thing for some time, but now i am trying again, and still there are problems. First of all, the documentation says, that in the target, there’s should be an exe, i don’t have any exe, so what do i put over there? I have 2 projects with cmakelist, and they are both libraries, one of them, requires some libs from the second project.
What i will do at this point instead, is turn off the jpeg support in the configuration, and it shouldn’t require the other library, but i can’t save the config after edit… I tried to turn off some stuff in cmake, and then hit build, but i don’t get anything usefull.
After i turn off what i want in the configuration, i hit build, and i don’t get any dll’s, nor do i get any .a files, what i get instead is some usless rubbish stuff. I tried to copy it back into the source file with cmakelist.txt, but then tit says the project is broken…
Because of that, i am not using cmake in order to compile, cause it doesn’t work what so ever.
I use Qt in order to compile that, but in qt, i don’t have the configuration menu, i can’t turn anything on or off. What i want to do, is find the file where the data is stored, turn it manually off, and then compile it using cmake but in qt.
But in which file are these options? I can’t configure it directly in Qt, in cmake it generates usless rubbish files, and it doesn’t change anything in the source configuration at all, so i have to turn them off manually.
And these are the files that cmake generates after hit build
Idk what to do with these things, in QT when i say build, it build the project, and i do get the dll’s and other usefull stuff.
It doesn’t edit the configuration as well after i hit build, there are no changes made, if i reload the file, it’s the same old default configuration with everything turned on.
I don’t know what “in QT” means (cmake-gui? - I have like 0 experience with that) but what you’re doing with CMake looks like just building. The files are somewhere in the build tree but typically you should install the project to get nice standard layout and all the find_package stuff from other projects working.
Build trees are not meant to be used by other projects.
@bambo09 It’s a little hard understanding what you’re trying to describe - you’ve verbally described operations you are doing rather than presenting a simple concrete CMakeLists, for instance.
As with many engineering tasks, you might want to take a step back and create a minimal verification example for yourself.
To create a library that produces a DLL:
CMAKE_MINIMUM_REQUIRED(VERSION 3.18)
PROJECT(DllTest)
# Tell cmake we want it to automate generating an export stub for the dll
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
ADD_LIBRARY(
mylib SHARED
mylib.cpp
)
> cmake -B out -G "Visual Studio 16 2019" .
...
> cmake --build out
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking Build System
Building Custom Rule C:/Users/oliver/tmp/cmake-dll/CMakeLists.txt
mylib.cpp
Auto build dll exports
Creating library C:/Users/oliver/tmp/cmake-dll/out/Debug/mylib.lib and object C:/Users/oliver/tmp/cmake-dll/out/De
bug/mylib.exp
mylib.vcxproj -> C:\Users\oliver\tmp\cmake-dll\out\Debug\mylib.dll
Building Custom Rule C:/Users/oliver/tmp/cmake-dll/CMakeLists.txt
Now you have a dll to experiment with linking. I would suggest adding a second library (shared or static) that links to it
ADD_LIBRARY(middle_lib SHARED middle_lib.cpp)
# hard-coded path is a bad idea outside an experiment.
TARGET_LINK_LIBRARIES(middle_lib c:/users/oliver/tmp/cmake-dll/out/Debug/mylib.lib)
Can’t find lept.pc in any of C:/Strawberry/c/lib/pkgconfig
use the PKG_CONFIG_PATH environment variable, or
specify extra search paths via ‘search_paths’
WHERE do i specify it?? I tried to put this PKG_CONFIG_PATH it in the cmakelist, and i get errors… comeone
Crap, never mind… Somehow after i thought i linked the library correctly, i had undefined references to errors, but this time during compile time, not building in cmake.
The reason why all this bullshit happens, was because of cmake… There was one path as variable to set, i set it multiple times, but after i hit generate or configure, the variable was set back to unknown path… I ignored it because i tought it was saved anyways, but it wasn’t. The only way to fix it, was to build the configuration, and then open the cmakecache and set the variable over there.
Kinda messed up considering that i lost at least 3 days because of it, somehow the rest of the configuration didn’t have these problems, it was only that one specific variable which somehow wasn’t saved, and the variable was the path to the required libraries. I tested it after and everything get compiled without problems.