Damien
Damien

Reputation: 33

CMAKE get a .so library on windows

I'm trying to compile a shared library with cmake to use it further with the "dlfcn" lib in a C program. I am on Windows with Cygwin, but I don't know how to use "dlfcn" with the shared libraries of windows (.dll and .dll.a) and my teammates are using Linux. So I would like to create not .dll and .dll.a libraires but a .so library. I'm a beginner with cmake, is there a possibility to do it or am I obliged to install a Linux VM ?

Upvotes: 0

Views: 1720

Answers (1)

Damien
Damien

Reputation: 33

So, thanks to @Florian, I finally made it. To the ones who want to know how it works, it's quite simple :

  • Create a new .cmake file :

    # this mandatory command will be the one that will make your cross-compiling work
    set(CMAKE_SYSTEM_NAME Linux)
    
    # indicate compilers (optional)
    set(CMAKE_C_COMPILER gcc)
    set(CMAKE_CXX_COMPILER g++)
    
  • When calling your cmake command, add an argument like this :

    cmake -DCMAKE_TOOLCHAIN_FILE=./myToolChainFile.cmake ..
    

Upvotes: 1

Related Questions