How to include source code written in C from another project in my own C ++ project in Visual Studio

I want to use Potrace for a C ++ project in Windows in Visual Studio, but I don't know how to incorporate Potrace into my project. I tried to compile C files using Cygwin and thus create a .a file and then link it to a visual studio, but that didn't work. Visual Studio was able to recognize the functions from Potrace, but when starting the test program with Potrace (Calling potrace_version ()), Visual Studio received the error message "LNK2019 unresolved external symbol _potrace_version referenced by function_main"

I got Ubuntu working using the technique described above and then compiled my code with: g ++ main.cpp backenddxf.cpp ImageManipulation.cpp./libubuntu/libpotrace.a -o test.out 'pkg-config --cflags --libs opencv

Do I have to compile the source code (Called "source distribution" on the website) into a lib file, and then link it to my project, in this case, how to do it? Or something I missed. I am using Visual Studio 2017 on Windows 10.

I should not understand the work of C ++, so a detailed explanation is very much appreciated.

+5
source share
1 answer

I worked with this answer from Yaakov to compile potrace to a .a file

./configure --prefix=/usr/x86_64-64-ming32/sys-root/mingw --host=x86_64-w64-mingw32 --with-libpotrace 

and then

 make 

After that, I used this Stuti Rastogi answer on how to link the .a file in Visual Studio.

+3
source

Source: https://habr.com/ru/post/1275804/


All Articles