0

I'm compiling a library for Android using QtCreator. After it's built, I need it to be copied to a specific location.

I was using QtCreator 4.0.3 with Qt 5.6 and NDK r11b

I'm now migrating my code to QtCreator 4.8.0 with Qt 5.12 and NDK r18b

With QtCreator 4.0.3 I used to have:

DESTDIR = <path to the place where I wish the binary to be copied>

And it worked perfectly (.so file was copied after it was generated)

With QtCreator 4.8.0 I get the error:

move libsde3p_cppunit-g.so <path to the place where I wish the binary to be copied>\libsde3p_cppunit-g.so
process_begin: CreateProcess(NULL, move libsde3p_cppunit-g.so <path to the place where I wish the binary to be copied>\libsde3p_cppunit-g.so, ...) failed.
make (e=2): Le fichier spécifié est introuvable.

I see that when this error is reported <my build folder>\build-cppunit-Android_for_armeabi_v7a_Clang_Qt_5_12_0_for_Android_ARMv7-Debug\libsde3p_cppunit-g.so exists while <my build folder>\build-cppunit-Android_for_armeabi_v7a_Clang_Qt_5_12_0_for_Android_ARMv7-Debug\android-build\libs\armeabi-v7a\libsde3p_cppunit-g.so does not yet. And I know QtCreator finally copies the lib from this first location to the second. So most likely, it tries to copy the library from the wrong location.

I tried some other alternatives:

Tried QMAKE_POST_LINK = copy... this is apparently never executed (QMAKE_POST_LINK = djdkdk does not report any error).

Tried custom targets:

custom_copy_step.target = foo.h
custom_copy_step.commands = $(COPY_FILE) $$shell_path($$OUT_PWD)\lib$${TARGET}.so $$shell_path(<path to the place where I wish the binary to be copied>
QMAKE_EXTRA_TARGETS += custom_copy_step
POST_TARGETDEPS += foo.h

This time it fails with error:

copy /y <my build folder>\build-cppunit-Android_for_armeabi_v7a_Clang_Qt_5_12_0_for_Android_ARMv7-Debug\libsde3p_cppunit-g.so <path to the place where I wish the binary to be copied>
Le fichier sp‚cifi‚ est introuvable.
make: *** [foo.h] Error 1

And I confirm the lib file is not present on disk, so looks like the command is executed before the .so is actually generated.

What instructions should I add to my .pro file to have the output .so file be copied to a specific location?

jpo38
  • 20,821
  • 10
  • 70
  • 151

1 Answers1

0

Could make it work with QMAKE_POST_LINK (needs a += instead of =):

QMAKE_POST_LINK += $(COPY_FILE) $$shell_path($$OUT_PWD)\lib$${TARGET}.so $$shell_path(<path to the place where I wish the binary to be copied>)
jpo38
  • 20,821
  • 10
  • 70
  • 151