LO Windows SDK - Compiler error: Unkown Platform

Hossein Nourikhah hossein at libreoffice.org
Wed Aug 3 22:09:36 UTC 2022


Hello Fatih,

The reason that you did not receive many responses is that this is not 
an officially supported way of building LibreOffice SDK examples, but 
rather a proof of concept. I hope that I can submit patches and merge it 
in the LibreOffice code repository soon.

You should also note that on Windows, the official tool for building 
LibreOffice examples (and LibreOffice itself) is Visual Studio 2019 or 
2022. With Visual Studio, you can build LibreOffice SDK examples using 
cmake, with a slight change compared to the CMakeLists.txt that was 
posted on the dev blog.

This is the LOROOT that I use, that refers to the LibreOffice folder 
inside "C:\Program Files":

set(LOROOT C:/Progra~1/LibreOffice)

Other than that, you only need to change this part:

target_link_libraries(example
     icppuhelper
     ipurpenvhelper
     icppu
     isalhelper
     isal
)

These are the names of .lib files that you can find in this folder:

C:\Program Files\LibreOffice\sdk\lib

For the definitions, WIN32 works, but LINUX also works for me.

add_definitions(-DWIN32)

For the cppumaker, the problem might be that you don't have the required 
directories in your system path. Try adding these directories to the 
Windows system path before opening Visual Studio or its command line:

C:\Program Files\LibreOffice\program
C:\Program Files\LibreOffice\sdk\bin

You should test cppumaker in the command prompt shown by selecting "x64 
Native Tools Command Prompt for VS 2022" before invoking cmake. Then, 
you should be able to see that two folders named "com" and "org" are 
created for you after running cmake.

After opening the solution in Visual Studio, you can easily build and 
run the project "example". The binary file "example.exe" should be built 
and run fine, and work as intended.

The CMakeLists.txt that I have used is attached.

I have also tested MSYS2, but the best that I could achieve was getting 
this error:

[2/2] Linking CXX executable example.exe
FAILED: example.exe
cmd.exe /C "cd . && C:\msys64\usr\bin\c++.exe   
CMakeFiles/example.dir/main.cpp.obj -o example.exe 
-Wl,--out-implib,libexample.dll.a 
-Wl,--major-image-version,0,--minor-image-version,0 
-LC:/Progra~1/LibreOffice/program   -LC:/Progra~1/LibreOffice/sdk/lib 
-licppuhelper  -lipurpenvhelper  -licppu  -lisalhelper  -lisal  
-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 
-luuid -lcomdlg32 -ladvapi32 && cd ."
/usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../x86_64-pc-msys/bin/ld: 
CMakeFiles/example.dir/main.cpp.obj:main.cpp:(.text+0x36): undefined 
reference to `cppu::bootstrap()'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Please note that I have used LINUX in the definitions, because otherwise 
it is assumed that on WIN32, Visual Studio is used:

add_definitions(-DLINUX)

I think using Visual Studio for now would be the available option.

Regards,
Hossein

On 29.07.2022 05:58, Fatih Yegin wrote:
> Doctor, is there any hope?
> 
> As an aside, here's how I setup my configuration:
> 
> 1. Install LO and sdk to default installation paths*
> 
> 2. Move them to "C:\"
> 
> 3. Install msys, and don't forget to update the msys and msys mingw64
> terminals with `pacman -Syu`**
> 
> 4. (Optional) Make msys shortcuts on "USER_NAME\Desktop" (especially
> mingw64 one)
> 
> 5. Install cmake according to this link:
> https://www.msys2.org/docs/cmake/
> 
> 6. Run setupsdkenv<...>.batch, ideally from cmd***
> 
> 7. Run msys's mingw64 environment from this terminal with `cmd /C ...`,
> preferably from the desktop shortcut****
> 
> 8. Configuration should be ready now.
> 
> 
> While writing these, it gave me an idea by the way. I have never tried
> to move the LO & sdk to msys root (C:\msys64\). In theory, if I setup
> the environment variables correctly, I should be able to compile the
> examples from msys & infer from their compile commands.
> 
> I can't try this rightaway, however I will try to send a follow up e-
> mail when I have spare time.
> 
> Kind regards,
> Fatih Yegin
> 
> 
> *This is important as otherwise installation will break with bunch of
> missing dll errors due to the ancient installer (My heartfelt apologies
> for not mentioning earlier, it was completely out of my mind). The
> reason I did this was to compile the examples, however it didn't work
> out.
> 
> **For installation steps:
> https://www.msys2.org/#installation
> 
> ***For unix tools use "C:\msys64\usr\bin", "msys64" part can change
> depending on your installation (This allows the execution of unix
> commands as part of msys from cmd as well, beware!).
> 
> ****This is also important. This way we can access the environment
> variables we had set up before (e.g. "$OO_SDK_HOME"). You can see these
> variables with `set` from msys.
> 
> On Tue, 2022-07-26 at 21:08 +0300, Fatih Yegin wrote:
>> I'm sorry, I have forgotten to mention that cmake doesn't generate
>> the
>> needed headers in Windows either. We must run the necessary cppumaker
>> command manually in the necessary directory.
>> 
>> Any ideas about how can solve these issues?
>> 
>> Thank you again, before hand.
>> 
>> On Tue, 2022-07-26 at 15:52 +0300, Fatih Yegin wrote:
>> > 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
>> >
>> 

-- 
Hossein Nourikhah, Ph.D.
Developer Community Architect
The Document Foundation (TDF)
Email: hossein at libreoffice.org
Wiki:  https://wiki.documentfoundation.org/User:Hossein
IRC:   hossein at libreoffice-dev room in LiberaChat Network
        irc://irc.libera.chat/#libreoffice-dev
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20220804/0271ce89/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: msys2-error.txt
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20220804/0271ce89/attachment-0001.txt>


More information about the LibreOffice mailing list