Fix znc-buildmod when linking with "ld --as-needed" #125

Closed
opened 2026-10-05 04:00:17 +02:00 by adam · 0 comments
Owner

Some distros (like Ubuntu since 11.10) use "ld --as-needed" by default which causes gcc (spawned by znc-buildmod) to ignore ${LIBS}. A simple fix is to move ${LIBS} after the name of the file to be compiled.

${CXX} ${CXXFLAGS} ${INCLUDES} ${LDFLAGS} ${MODLINK} -o "${MOD}.so" "${FILE}" ${LIBS} 

Be careful about the order of the parameters when using gcc; the -l option is a linker option, and thus needs to be placed AFTER the name of the file to be compiled. This is quite different from the normal option syntax. If you place the -l option before the filename, it may fail to link at all, and you can end up with mysterious errors.

http://tldp.org/HOWTO/Program-Library-HOWTO/static-libraries.html
http://stackoverflow.com/questions/7824439/c-math-linker-problems-on-ubuntu-11-10

Some distros (like Ubuntu since 11.10) use "ld --as-needed" by default which causes gcc (spawned by znc-buildmod) to ignore ${LIBS}. A simple fix is to move ${LIBS} after the name of the file to be compiled. ``` bash ${CXX} ${CXXFLAGS} ${INCLUDES} ${LDFLAGS} ${MODLINK} -o "${MOD}.so" "${FILE}" ${LIBS} ``` > Be careful about the order of the parameters when using gcc; the -l option is a linker option, and thus needs to be placed AFTER the name of the file to be compiled. This is quite different from the normal option syntax. If you place the -l option before the filename, it may fail to link at all, and you can end up with mysterious errors. http://tldp.org/HOWTO/Program-Library-HOWTO/static-libraries.html http://stackoverflow.com/questions/7824439/c-math-linker-problems-on-ubuntu-11-10 <!-- github-sync-id:5778834 -->
adam closed this issue 2026-10-05 04:00:17 +02:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#125