Building and linking C library on Windows with Github Actions

229 views Asked by At

I am attempting to build and link a modified version of LAME's libmp3lame.a C library into a C++ audio plugin application. I am using the Pamplejuce template for the plugin's CMake file and a Github action script to build for Mac, Linux, and Windows. The Mac and Linux builds work successfully, but the Windows build has errors when linking.

In the github action, I build LAME with the following command:

./configure CFLAGS="-fPIC" --disable-frontend
make clean
make

Then, in the CMakeLists.txt for the C++ application, I have the following command to link it:

target_link_libraries("${PROJECT_NAME}"
    PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/Source/lib/lame/libmp3lame/.libs/libmp3lame.a)

During the build process of the C++ application, the Windows build fails with the following error:

lld-link: error: undefined symbol: ___chkstk_ms
>>> referenced by libmp3lame.a(lame.o):(lame_encode_flush)
>>> referenced by libmp3lame.a(bitstream.o):(do_gain_analysis)
>>> referenced by libmp3lame.a(psymodel.o):(vbrpsy_attack_detection)

>>> referenced 9 more times



lld-link: error: undefined symbol: __mingw_vfprintf

>>> referenced by libmp3lame.a(util.o):(.text)



lld-link: error: undefined symbol: __mingw_vsprintf

>>> referenced by libmp3lame.a(id3tag.o):(.text)

This question suggests that the issue could be with an outdated version of MinGW. However, running gcc --version gives gcc.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sanders) 11.2.0, which seems fine?

Inspired by this question, I also tried adding a step to uninstall mingw and reinstall it with msys2/setup-msys2@v2. However, this led to LAME's configure file failing: configure: error: C compiler cannot create executables.

What do I need to change for the program to link correctly?

I'm new to developing C/C++ code for Windows, so please let me know what additional information you need to answer this question.

0

There are 0 answers