'LibreOffice C++ API activation ('soffice') monopolizes terminal
I am using Ubuntu 20.04.4 LTS and have just installed the package libreoffice-dev.
The intention is to run the C++ DocumentLoader sample noted here. (The 3 files constituting the sample may be viewed here.)
The instructions are mostly embedded in the sample Makefile. Here is what happens:
The soffice command opened a new LibreOffice window - but did not actually finish (ie: no 'ready' message).
Q1: Is this expected behaviour?
It's catch-22. I'm prevented from running make DocumentLoader.run (or any) command but if I manually close the LibreOffice window (whereupon terminal bursts back into life) I am able to compile (but not successfully run) the program - as follows:
daz@daz-NUC8i7BEH:~/mpa/LO-SDK$ soffice "--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"
daz@daz-NUC8i7BEH:~/mpa/LO-SDK$ make DocumentLoader.run
cd /home/daz/libreoffice7.3_sdk/LINUXexample.out/bin && DocumentLoader -env:URE_MORE_TYPES=file://"/usr/lib/libreoffice/program/types/offapi.rdb" "/home/daz/libreoffice7.3_sdk/matt/test.odt"
DocumentLoader.cxx has started. nCount=1
Error: cannot establish a connection using 'uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager':
loading component library </libmergedlo.so> failed /build/libreoffice-SshRy0/libreoffice-7.3.1~rc3/cppuhelper/source/shlib.cxx:311
make: *** [Makefile:68: DocumentLoader.run] Error 1
daz@daz-NUC8i7BEH:~/mpa/LO-SDK$
Q2: Have I just made a procedural error?
Here is the actual Makefile ... [%.run: is Makefile:66]
# Builds the C++ DocumentLoader example of the SDK.
# From here: https://api.libreoffice.org/examples/cpp/DocumentLoader/
#PRJ=../../.. Original
PRJ=$(OO_SDK_HOME)
SETTINGS=$(PRJ)/settings
include $(SETTINGS)/settings.mk
include $(SETTINGS)/std.mk
# Define non-platform/compiler specific settings
COMPONENT_NAME=DocumentLoader
OUT_COMP_INC = $(OUT_INC)/$(COMPONENT_NAME)
OUT_COMP_GEN = $(OUT_MISC)/$(COMPONENT_NAME)
OUT_COMP_OBJ=$(OUT_OBJ)/$(COMPONENT_NAME)
CXXFILES = DocumentLoader.cxx
OBJFILES = $(patsubst %.cxx,$(OUT_SLO_COMP)/%.$(OBJ_EXT),$(CXXFILES))
ENV_OFFICE_TYPES=-env:URE_MORE_TYPES=$(URLPREFIX)$(OFFICE_TYPES)
# Targets
.PHONY: ALL
ALL : \
CppDocumentLoaderExample
include $(SETTINGS)/stdtarget.mk
$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
$(OUT_BIN)/DocumentLoader$(EXE_EXT) : $(OUT_COMP_OBJ)/DocumentLoader.$(OBJ_EXT)
-$(MKDIR) $(subst /,$(PS),$(@D))
-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
ifeq "$(OS)" "WIN"
$(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(basename $(@F)).map \
$< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
else
$(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
$(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB)
ifeq "$(OS)" "MACOSX"
$(INSTALL_NAME_URELIBS_BIN) $@
endif
endif
CppDocumentLoaderExample : $(OUT_BIN)/DocumentLoader$(EXE_EXT)
@echo --------------------------------------------------------------------------------
@echo The example loads the "$(QM)test.odt$(QM)" document in the DocumentLoader example directory.
@echo If you want to load your own document, please use:
@echo $(SQM) $(SQM)DocumentLoader -env:URE_MORE_TYPES="$(QM)<fileurl_office_types_rdb>$(QM)" "$(QM)filename$(QM)" [connection_url]
@echo -
@echo Use the following command to execute the example!
@echo -
@echo $(MAKE) DocumentLoader.run
@echo -
@echo NOTE: This example does not use the new UNO bootstrap mechanism, it uses still a socket
@echo $(SQM) $(SQM)connection. The example use the defaultBootstrap_InitialComponentContext method and provides
@echo $(SQM) $(SQM)the additional office types via the UNO environment variable -env:URE_MORE_TYPES=...
@echo $(SQM) $(SQM)Before you can run this example you have to start your office in listening mode.
@echo -
@echo $(SQM) $(SQM)soffice "$(QM)--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager$(QM)"
@echo --------------------------------------------------------------------------------
%.run: $(OUT_BIN)/DocumentLoader$(EXE_EXT)
# cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_OFFICE_TYPES) $(subst \\,/,$(subst /,$(PS),"$(OO_SDK_HOME)/examples/cpp/DocumentLoader/test.odt"))
cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_OFFICE_TYPES) $(subst \\,/,$(subst /,$(PS),"/home/daz/libreoffice7.3_sdk/matt/test.odt"))
.PHONY: clean
clean :
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/DocumentLoader*))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

