danomatika / ofxPd

(maintained) a Pure Data addon for OpenFrameworks using libpd
Other
202 stars 45 forks source link

linking error while building on win11/mingw64 #95

Closed Ant1r closed 10 months ago

Ant1r commented 1 year ago

I have trouble with building ofxPd examples on a freshly installed win11/mingw64; I'm using the make method (no IDE).

The compilation itself went fine, but the linking fails, with every object file (pd/libpd/ofxPd/ofApp) triggerring numerous errors involving __imp_libpd_* versions of the libpd functions, typically:

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Admin/Documents/OF/of_v0.11.2_msys2_mingw64_release/addons/obj/msys2/Release/ofxPd/libs/libpd/libpd_wrapper/util/z_queued.o:z_queued.c:(.text+0x95d): undefined reference to '__imp_libpd_init'

Am I doing something wrong?

Ant1r commented 1 year ago

Could it be related to the order the files are linked? Currently, the order is:

MAIN: main.o ofApp.o OFXPD: ofxPd.o LIBPD: ringbuffer.o z_queued.o z_hooks.o z_libpd.o PD: bob~.o bonk~.o (...) d_array.o d_dac.o (...) STATIC: libopenFrameworks.a libkiss.a (...) DYN: -lcairo -lz (...)

But the weird thing is that both ofApp.o (or ofxPd.o) and PD objects (like d_array.o) trigger the linking error, while they are located both side of LIBPD inclusion... So I don't see what order could be better.

Ant1r commented 1 year ago

Note: I also had to remove ADDON_CFLAGS += -DHAVE_LIBDL from addon_config.mk because compiler didn't find dlfcn.h, but that seems unrelated to the issue, and I don't need dynamic loading anyway.

But I'm still stuck on undefined reference to '__imp_*'... Ping @danomatika , any hint?

danomatika commented 1 year ago

I don’t know. It’s a usually an issue with how symbols are exported on windows.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Jun 23, 2023, at 12:54 PM, Antoine Rousseau @.***> wrote:

 Note: I also had to remove ADDON_CFLAGS += -DHAVE_LIBDL from addon_config.mk because compiler didn't find dlfcn.h, but that seems unrelated to the issue, and I don't need dynamic loading anyway.

But I'm still stuck on undefined reference to '_imp*' ... Ping @danomatika , any hint?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

Ant1r commented 1 year ago

OK thanks. So maybe this can be controlled by some compiler flag? I'm just starting to work on Windows again, which I haven't done since around 1998 :-)

Ant1r commented 1 year ago

OK! I have a working solution: for msys2(and I guess for vs too) we have to add: ADDON_CFLAGS += -DPD_INTERNAL which is used by m_pd.h for setting the EXTERN macro.

danomatika commented 10 months ago

Closing as a solution was found. Also, this solution is now in the master branch.