Fix Visual Studio shared library build

Todo: fluid-shared can't (yet) be built agains the shared fltk lib
  because of some linker errors. Needs investigation.

Note: fluid-shared is basically a test program to demonstrate linking
  against the shared FLTK libs but doesn't work yet using VS (MSVC).
  This is no problem for the functionality.
This commit is contained in:
Albrecht Schlosser 2023-09-12 23:18:46 +02:00
parent e44a988c4a
commit ede381c005
5 changed files with 17 additions and 10 deletions

View File

@ -126,8 +126,8 @@ public:
}; // class Fl_String
// ---- Non-member functions
extern Fl_String operator+(const Fl_String &lhs, const Fl_String &rhs);
extern Fl_String operator+(const Fl_String &lhs, const char *rhs);
extern bool operator==(const Fl_String &lhs, const Fl_String &rhs);
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const Fl_String& rhs);
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const char* rhs);
FL_EXPORT bool operator==(const Fl_String & lhs, const Fl_String & rhs);
#endif // _FL_Fl_String_H_

View File

@ -166,9 +166,12 @@ if (OPTION_BUILD_SHARED_LIBS)
list (APPEND FLUID_TARGETS fluid-shared)
add_executable (fluid-shared fluid.cxx fluid.h)
if (MSVC)
target_link_libraries (fluid-shared fluid-lib fltk_SHARED)
# Todo: this should link against fltk_SHARED rather than fltk_images but for an unknown
# reason this would issue link errors (about 25 undefined symbols). Needs investigation.
# AlbrechtS: Sep. 12, 2023
target_link_libraries (fluid-shared PRIVATE fluid-lib fltk_images) # should be: fltk_SHARED)
else ()
target_link_libraries (fluid-shared fluid-lib fltk_images_SHARED)
target_link_libraries (fluid-shared PRIVATE fluid-lib fltk_images_SHARED)
endif (MSVC)
endif ()

View File

@ -85,7 +85,7 @@ if (OPTION_BUILD_SHARED_LIBS)
FL_ADD_LIBRARY (fltk_png SHARED "${PNG_SRCS}")
if (FLTK_USE_BUILTIN_ZLIB)
target_link_libraries (fltk_png_SHARED fltk_z_SHARED)
target_link_libraries (fltk_png_SHARED fltk_z)
else()
target_link_libraries (fltk_png_SHARED ${FLTK_ZLIB_LIBRARIES})
endif ()

View File

@ -831,19 +831,19 @@ if (OPTION_BUILD_SHARED_LIBS AND MSVC)
target_link_libraries (fltk_SHARED ${OPTIONAL_LIBS})
if (FLTK_USE_BUILTIN_JPEG)
target_link_libraries (fltk_SHARED fltk_jpeg_SHARED)
target_link_libraries (fltk_SHARED fltk_jpeg)
else()
target_link_libraries (fltk_SHARED ${FLTK_JPEG_LIBRARIES})
endif ()
if (FLTK_USE_BUILTIN_PNG)
target_link_libraries (fltk_SHARED fltk_png_SHARED)
target_link_libraries (fltk_SHARED fltk_png)
else()
target_link_libraries (fltk_SHARED ${FLTK_PNG_LIBRARIES})
endif ()
if (FLTK_USE_BUILTIN_ZLIB)
target_link_libraries (fltk_SHARED fltk_z_SHARED)
target_link_libraries (fltk_SHARED fltk_z)
else()
target_link_libraries (fltk_SHARED ${FLTK_ZLIB_LIBRARIES})
endif ()

View File

@ -169,7 +169,11 @@ SET (UNITTEST_SRCS
)
if (OPENGL_FOUND)
set (UNITTEST_LIBS fltk_gl fltk ${OPENGL_LIBRARIES})
set (UNITTEST_LIBS_SHARED fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES})
if (MSVC)
set (UNITTEST_LIBS_SHARED fltk_SHARED ${OPENGL_LIBRARIES})
else ()
set (UNITTEST_LIBS_SHARED fltk_gl_SHARED fltk_SHARED ${OPENGL_LIBRARIES})
endif ()
else ()
set (UNITTEST_LIBS fltk)
set (UNITTEST_LIBS_SHARED fltk_SHARED)