Creating a portable library to run on both linux and windows

前端 未结 5 1738
野趣味
野趣味 2020-12-23 18:20
gcc (GCC) 4.7.2

Hello,

I am creating a shared library that will compile on linux and a dll that will compile on windows using the same sour

5条回答
  •  难免孤独
    2020-12-23 18:32

    Instead of writing a header file yourself, you can also let CMake generate one for the building compiler using CMake's generate_export_header like this (examples taken from the linked page):

    add_library(libfoo foo.cpp)
    generate_export_header(libfoo)
    #include "libfoo_export.h"
    class LIBFOO_EXPORT FooClass {
        int bar;
    };

提交回复
热议问题