milu
milu

Reputation: 51

Create one exe file with buil-in static libraries

I have project in openCV, created as Makefile application under eclipse (MinGW/Windows 8 os). I need to create one executable file so that there won't be required any other dlls while running app on other computer without openCV installed.

I have also compiled openCV sources as static library. That is what my Makefile (draft) looks like:

all:    
    gcc -static -I"C:\opencv\build\include" -L"lib" main.c -lws2_32 -lopencv_core244.dll -lopencv_highgui244.dll -lopencv_imgproc244.dll -o bcast.exe

After building exec doesn't contain libs. What am i doing wrong?

Thanks in advance.

Upvotes: 3

Views: 1699

Answers (1)

berak
berak

Reputation: 39806

You're expected to link *.lib files, not *.dll (Dynamic-Link Library).

So, that should be :

g++ -I"C:\opencv\build\include" -L"lib" main.c -lws2_32 -lopencv_core244.lib -lopencv_highgui244.lib -lopencv_imgproc244.lib -o bcast.exe

(You should consider using g++ for this, it's a c++ library.) After that your makefile will produce 1 .exe file, no libs.

Honestly, did you really recompile the opencv libs statically (with -DBUILD_SHARED_LIBS=OFF)? I'm having doubts here.

Upvotes: 1

Related Questions