Skip to content

Commit

Permalink
windows: fix undefined reference problems
Browse files Browse the repository at this point in the history
- created separate subdirectories for libbareos and libbareoscfg
- added an extra define for DLL_IMP_EXP specifically for ConfigurationParser
- created manually .def file and auto build of import library for libbareoscfg
  • Loading branch information
franku committed Sep 20, 2018
1 parent d12f266 commit 1867d11
Show file tree
Hide file tree
Showing 89 changed files with 44 additions and 90 deletions.
5 changes: 5 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
${CMAKE_SOURCE_DIR}/src/win32/include
${CMAKE_SOURCE_DIR}/src/win32/compat/include
)

#used for import libraries:
set(WINDOWS_IMPORT_LIB_DIRECTORY ${PROJECT_BINARY_DIR}/src/lib/bareos)
link_directories(${WINDOWS_IMPORT_LIB_DIRECTORY})

set(HAVE_WIN32 1)

set(WINDOWS_LIBRARIES ws2_32)
Expand Down
13 changes: 13 additions & 0 deletions core/src/include/baconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,23 @@ void InitWinAPIWrapper();
#define DLL_IMP_EXP _declspec(dllexport)
#define CATS_IMP_EXP _declspec(dllexport)
#define SD_IMP_EXP _declspec(dllexport)
#define BAREOSCFG_DLL_IMP_EXP _declspec(dllimport)
#elif defined(BUILDING_BAREOS_DLL)
#define DLL_IMP_EXP _declspec(dllexport)
#define CATS_IMP_EXP _declspec(dllexport)
#define SD_IMP_EXP _declspec(dllexport)
#define BAREOSCFG_DLL_IMP_EXP _declspec(dllimport)
#elif defined(BUILDING_BAREOSCFG_DLL)
#define DLL_IMP_EXP _declspec(dllexport)
#define CATS_IMP_EXP _declspec(dllexport)
#define SD_IMP_EXP _declspec(dllexport)
#define BAREOSCFG_DLL_IMP_EXP _declspec(dllexport)
#elif defined(USING_DLL)
#define DLL_IMP_EXP _declspec(dllimport)
#define CATS_IMP_EXP _declspec(dllimport)
#define SD_IMP_EXP _declspec(dllimport)
#else
#define BAREOSCFG_DLL_IMP_EXP
#define DLL_IMP_EXP
#define CATS_IMP_EXP
#define SD_IMP_EXP
Expand All @@ -123,6 +135,7 @@ void InitWinAPIWrapper();

#define ClearThreadId(x) x = 0

#define BAREOSCFG_DLL_IMP_EXP
#define DLL_IMP_EXP
#define CATS_IMP_EXP
#define SD_IMP_EXP
Expand Down
103 changes: 14 additions & 89 deletions core/src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,99 +17,24 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

include_directories(
${OPENSSL_INCLUDE_DIRS}
${PTHREAD_INCLUDE_DIRS}
${FASTLZ_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${ACL_INCLUDE_DIRS}
${LZO2_INCLUDE_DIRS}
${CAP_INCLUDE_DIRS}
${WRAP_INCLUDE_DIRS}
)

set(INCLUDE_FILES ../include/baconfig.h ../include/bareos.h
../include/bc_types.h ../include/config.h
../include/jcr.h ../include/version.h
address_conf.h alist.h attr.h base64.h berrno.h
bits.h bpipe.h breg.h bregex.h bsock.h
bsock_tcp.h btime.h btimers.h cbuf.h
crypto.h crypto_cache.h devlock.h dlist.h fnmatch.h
guid_to_name.h htable.h ini.h lex.h lib.h lockmgr.h
md5.h mem_pool.h message.h mntent_cache.h ordered_cbuf.h parse_conf.h
plugins.h qualified_resource_name_type_converter.h queue.h rblist.h
runscript.h rwlock.h scsi_crypto.h scsi_lli.h scsi_tapealert.h sellist.h
serial.h sha1.h smartall.h status.h tls.h tls_conf.h tree.h var.h
watchdog.h workq.h)

set (BAREOS_SRCS address_conf.cc alist.cc attr.cc attribs.cc base64.cc
berrno.cc bget_msg.cc binflate.cc bnet_server_tcp.cc bnet.cc bpipe.cc
breg.cc bregex.cc bsnprintf.cc bsock.cc bsock_tcp.cc
bsys.cc btime.cc btimers.cc cbuf.cc compression.cc
connection_pool.cc cram-md5.cc crypto.cc crypto_cache.cc crypto_gnutls.cc
crypto_none.cc crypto_nss.cc crypto_openssl.cc crypto_wrap.cc daemon.cc
devlock.cc dlist.cc edit.cc fnmatch.cc guid_to_name.cc hmac.cc htable.cc
jcr.cc json.cc lockmgr.cc md5.cc mem_pool.cc message.cc mntent_cache.cc
output_formatter.cc ordered_cbuf.cc passphrase.cc path_list.cc plugins.cc
bpoll.cc priv.cc
queue.cc rblist.cc runscript.cc rwlock.cc scan.cc scsi_crypto.cc scsi_lli.cc
sellist.cc serial.cc sha1.cc signal.cc smartall.cc tls.cc
tls_gnutls.cc tls_conf_base.cc tls_conf_psk.cc tls_conf_cert.cc tls_openssl.cc tls_openssl_crl.cc
tls_openssl_private.cc tree.cc util.cc var.cc
watchdog.cc workq.cc)

IF(HAVE_WIN32)
LIST(APPEND BAREOS_SRCS
../win32/compat/compat.cc
../win32/compat/glob.cc
../win32/compat/print.cc
../win32/compat/winapi.cc
)
ELSE()
LIST(APPEND BAREOS_SRCS
scsi_tapealert.cc)
ENDIF()

add_library(bareos SHARED ${BAREOS_SRCS})

target_link_libraries(bareos
${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES} ${FASTLZ_LIBRARIES} ${ZLIB_LIBRARIES}
${ACL_LIBRARIES} ${LZO2_LIBRARIES} ${CAP_LIBRARIES} ${WRAP_LIBRARIES} ${CAM_LIBRARIES}
${WINDOWS_LIBRARIES} ${JANSSON_LIBRARIES})

set (BAREOSCFG_SRCS ini.cc lex.cc parse_bsr.cc )



set (BAREOS_STATIC_SRCS parse_conf.cc res.cc qualified_resource_name_type_converter.cc)

IF(HAVE_WIN32)
add_library(bareosstatic STATIC ${BAREOS_STATIC_SRCS})
target_link_libraries(bareosstatic bareoscfg)
ELSE()
LIST(APPEND BAREOSCFG_SRCS ${BAREOS_STATIC_SRCS})
ENDIF()

add_library(bareoscfg SHARED ${BAREOSCFG_SRCS})
target_link_libraries(bareoscfg bareos ${JANSSON_LIBRARIES})

INSTALL(TARGETS bareos DESTINATION ${libdir})
INSTALL(TARGETS bareoscfg DESTINATION ${libdir})

set_target_properties(bareoscfg PROPERTIES VERSION "${VERSION}"
SOVERSION "${SOVERSION}"
)

set_target_properties(bareos PROPERTIES VERSION "${VERSION}"
SOVERSION "${SOVERSION}"
)
IF(HAVE_WIN32)
set_target_properties(bareoscfg PROPERTIES DEFINE_SYMBOL "BUILDING_DLL")
set_target_properties(bareos PROPERTIES DEFINE_SYMBOL "BUILDING_DLL")
ENDIF()
../include/bc_types.h ../include/config.h
../include/jcr.h ../include/version.h
address_conf.h alist.h attr.h base64.h berrno.h
bits.h bpipe.h breg.h bregex.h bsock.h
bsock_tcp.h btime.h btimers.h cbuf.h
crypto.h crypto_cache.h devlock.h dlist.h fnmatch.h
guid_to_name.h htable.h ini.h lex.h lib.h lockmgr.h
md5.h mem_pool.h message.h mntent_cache.h ordered_cbuf.h parse_conf.h
plugins.h qualified_resource_name_type_converter.h queue.h rblist.h
runscript.h rwlock.h scsi_crypto.h scsi_lli.h scsi_tapealert.h sellist.h
serial.h sha1.h smartall.h status.h tls.h tls_conf.h tree.h var.h
watchdog.h workq.h)

INSTALL(FILES ${INCLUDE_FILES} DESTINATION ${includedir})

add_subdirectory(bareoscfg)
add_subdirectory(bareos)

IF(NOT HAVE_WIN32 AND GTEST_FOUND)
add_subdirectory(unittests)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion core/src/lib/parse_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class QualifiedResourceNameTypeConverter;
/*
* New C++ configuration routines
*/
class DLL_IMP_EXP ConfigurationParser {
class BAREOSCFG_DLL_IMP_EXP ConfigurationParser {
public:
std::string cf_; /* Config file parameter */
LEX_ERROR_HANDLER *scan_error_; /* Error handler if non-null */
Expand Down
11 changes: 11 additions & 0 deletions core/src/win32/compat/include/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,22 @@
#define DLL_IMP_EXP _declspec(dllexport)
#define CATS_IMP_EXP _declspec(dllexport)
#define SD_IMP_EXP _declspec(dllexport)
#elif defined(BUILDING_BAREOS_DLL)
#define DLL_IMP_EXP _declspec(dllexport)
#define CATS_IMP_EXP _declspec(dllexport)
#define SD_IMP_EXP _declspec(dllexport)
#define BAREOSCFG_DLL_IMP_EXP _declspec(dllimport)
#elif defined(BUILDING_BAREOSCFG_DLL)
#define DLL_IMP_EXP _declspec(dllexport)
#define CATS_IMP_EXP _declspec(dllexport)
#define SD_IMP_EXP _declspec(dllexport)
#define BAREOSCFG_DLL_IMP_EXP _declspec(dllexport)
#elif defined(USING_DLL)
#define DLL_IMP_EXP _declspec(dllimport)
#define CATS_IMP_EXP _declspec(dllimport)
#define SD_IMP_EXP _declspec(dllimport)
#else
#define BAREOSCFG_DLL_IMP_EXP
#define DLL_IMP_EXP
#define CATS_IMP_EXP
#define SD_IMP_EXP
Expand Down

0 comments on commit 1867d11

Please sign in to comment.