3

I want to compile all dependencies etc and shared libraries into the binary?

How to do that?

g++ -std=c++11 txtocr.cpp -o txtocr -llept -ltesseract

Tesseract depends on leptonica and some shared tesseract libraries.. But how to compile everything into the binary so it would be 100% portable

clarkk
  • 27,151
  • 72
  • 200
  • 340
  • Possible duplicate of [Convert shared library to static library?](http://stackoverflow.com/questions/6302954/convert-shared-library-to-static-library) – Richard Critten Mar 21 '17 at 12:06
  • No, I want to compile everything into one binary – clarkk Mar 21 '17 at 12:08
  • @clarkk That's what static libraries do :) . – TartanLlama Mar 21 '17 at 12:10
  • As the answer(s) in the duplicate say: If you only have a shared library you will need to source of it to build a static library and then link with the static library. – Richard Critten Mar 21 '17 at 12:10
  • @TartanLlama Not really. Static libraries are nothing more than collections of object files. If you want to have a static library without any dependencies you have to extract the object files from the shared libraries, which is not possible (since a shared library is more like an executable file). – Some programmer dude Mar 21 '17 at 12:14
  • For the OP: What you seem to be wanting is static *linking*, so the executable program doesn't depend on any shared libraries. Try adding the linker flag `-static`. – Some programmer dude Mar 21 '17 at 12:15

1 Answers1

-1

I believe the answer is "It depends". If you only have the shared library without the code of the library I am afraid the answer will be NO as not all information you need in order to build a static application are within your dynamic library.

Stefano
  • 3,981
  • 8
  • 36
  • 66