Hello, I am experimenting with LO SDK and using cmake to compile according to this page: https://dev.blog.documentfoundation.org/2022/04/19/using-cmake-to-build-libreoffice-cpp-sdk-examples/ This works great on Linux. However, I am having build errors on Windows. I believe, root cause of this problem is unkown platform error from sal library. Yet, I can't solve this even though I explicitly specify the OS within compile commands. I have added these errors briefly on the attachements in Build_errors.txt with the addition of CMakeLists.txt file and compile_commands.json file. For the build environment, I use MSYS's MINGW64 environment (additional info can be found at: https://www.msys2.org/docs/environments/). I can share my configuration steps with a secondary e-mail if needed. Thank you. Best Regards, Fatih Yeğin
Attachment:
compile_commands.json
Description: application/json
#Cmake minimum cmake_minimum_required(VERSION 3.15) #C++ standard set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) #Set project properties project( Experiments DESCRIPTION "My custom experiments." LANGUAGES CXX ) #Set OS specific variables if(UNIX AND NOT APPLE) add_compile_definitions("LINUX") set(LIBRE_ROOT "/usr/lib/libreoffice") set(LIBRE_SDK "${LIBRE_ROOT}/sdk") set(CPPUMAKER "${LIBRE_SDK}/bin/cppumaker") elseif(WIN32) add_compile_definitions( WIN32 WNT _DLL CPPU_ENV=gcc3 ) set(LIBRE_ROOT "C:/LibreOffice") set(LIBRE_SDK "C:/LibreOffice/sdk") set(CPPUMAKER "${LIBRE_SDK}/bin/cppumaker.exe") elseif(APPLE) add_compile_definitions("MACOSX") #TODO: Apple will be defined later #set(LIBRE_ROOT /usr/lib/libreoffice) #set(LIBRE_SDK ${LIBRE_ROOT}/sdk) #set(CPPUMAKER ${LIBRE_SDK}/bin/cppumaker) endif() if(NOT DEFINED LIBRE_ROOT AND NOT DEFINED LIBRE_SDK) if(APPLE) message(FATAL_ERROR "Cannot build for Apple, sorry!") else() message(FATAL_ERROR "Unknown architecture!") endif() endif() #Set necessary variables set(EXE_NAME experiments) set(BIN_DIR "${CMAKE_SOURCE_DIR}/bin") set(LIB_DIR "${CMAKE_SOURCE_DIR}/lib") set(PROJ_HEADERS_DIR "${CMAKE_SOURCE_DIR}") set(PROJ_SOURCES_DIR "${CMAKE_SOURCE_DIR}") set(LIBRE_LOCAL_HEADERS_DIR "${CMAKE_SOURCE_DIR}/../libreoffice-headers") #Make necessary directories file( MAKE_DIRECTORY ${BIN_DIR} ${LIB_DIR} ) #Configure where to put libraries set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_DIR}) #Configure where to put executable set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR}) #Compile libre cpp headers if(NOT EXISTS ${LIBRE_LOCAL_HEADERS_DIR}) file(MAKE_DIRECTORY ${LIBRE_LOCAL_HEADERS_DIR}) execute_process( COMMAND ${CPPUMAKER} -Gc -C "${LIBRE_ROOT}/program/types.rdb" "${LIBRE_ROOT}/program/types/offapi.rdb" WORKING_DIRECTORY "${LIBRE_LOCAL_HEADERS_DIR}" ) endif() #Make libre_libs library target file(GLOB_RECURSE LIBRE_HEADERS ${LIBRE_LOCAL_HEADERS_DIR}/*.hpp ${LIBRE_LOCAL_HEADERS_DIR}/*.hdl ${LIBRE_SDK}/include/*.hxx ${LIBRE_SDK}/include/*.h) add_library(libre_libs SHARED ${LIBRE_HEADERS}) set_target_properties(libre_libs PROPERTIES LINKER_LANGUAGE CXX) #Make proj_libs library target #file(GLOB_RECURSE PROJ_HEADERS ${PROJ_HEADERS_DIR}/*.hpp) #add_library(proj_libs SHARED ${PROJ_HEADERS}) #set_target_properties(proj_libs PROPERTIES LINKER_LANGUAGE CXX) #Make executable target add_executable(${EXE_NAME} ${PROJ_SOURCES_DIR}/experiment.cpp) #Include directories target_include_directories( ${EXE_NAME} PUBLIC ${LIBRE_LOCAL_HEADERS_DIR} PUBLIC ${PROJ_HEADERS_DIR} PUBLIC ${PROJ_SOURCES_DIR} PUBLIC ${LIBRE_SDK}/include ) #Link directories target_link_directories( ${EXE_NAME} PRIVATE ${LIBRE_SDK}/lib PRIVATE ${LIBRE_ROOT}/program ) #Link libraries target_link_libraries( ${EXE_NAME} PUBLIC libre_libs #PUBLIC proj_libs -luno_sal -luno_cppu -luno_cppuhelpergcc3 -luno_salhelpergcc3 -lunoidllo -lxmlreaderlo -lreglo )
In file included from C:/LibreOffice/sdk/include/rtl/textenc.h:27, from C:/LibreOffice/sdk/include/rtl/string.hxx:43, from C:\Users\VBox\Desktop\experiments\experiment.cpp:4: C:/LibreOffice/sdk/include/sal/types.h:250:5: error: #error ("unknown platform") 250 | # error("unknown platform") | ^~~~~ In file included from C:/LibreOffice/sdk/include/osl/interlck.h:29, from C:/LibreOffice/sdk/include/rtl/string.h:29, from C:/LibreOffice/sdk/include/rtl/string.hxx:44: C:/LibreOffice/sdk/include/sal/saldllapi.h:34:23: error: 'SAL_DLLPUBLIC_IMPORT' does not name a type; did you mean 'SAL_DLLPUBLIC'? 34 | #define SAL_DLLPUBLIC SAL_DLLPUBLIC_IMPORT | ^~~~~~~~~~~~~~~~~~~~ [And goes on...]