Menu

#22 link error on windows with cygwin

closed
Other (7)
7
2010-06-02
2010-04-22
No

From e-mail list:

I’m trying to find a way to build libsexp.a on a Windows machine and then link this library into an application.

I used cygwin to configure sexp. Then I used the mingw that came with Qt to build the library. This appeared to be a success.

When I tried to link my project to this library, though (using the same mingw compiler) I got this response:

Warning: .drectve ‘-aligncomm:_pd_cache,2 ‘ unrecognized
Warning: .drectve ‘-aligncomm:_sexp_t_cache,2 ‘ unrecognized
Warning: .drectve ‘-aligncomm:___CTOR_LIST__,2 ‘ unrecognized
Warning: .drectve ‘-aligncomm:___DTOR_LIST__,2 ‘ unrecognized
C:\cygwin\opt\sexp\lib/libsexp.a(event_temp.o):event_temp.cL.text+0x18f): undefined reference to ‘__getreent’
C:\cygwin\opt\sexp\lib/libsexp.a(event_temp.o):event_temp.cL.text+0x18f): undefined reference to ‘__assert_func’
C:\cygwin\opt\sexp\lib/libsexp.a(event_temp.o):event_temp.cL.text+0x18f): undefined reference to ‘__assert_func’
C:\cygwin\opt\sexp\lib/libsexp.a(event_temp.o):event_temp.cL.text+0x18f): undefined reference to ‘__assert_func’
C:\cygwin\opt\sexp\lib/libsexp.a(event_temp.o):event_temp.cL.text+0x18f): undefined reference to ‘__assert_func’
C:\cygwin\opt\sexp\lib/libsexp.a(event_temp.o):event_temp.cL.text+0x18f): undefined reference to ‘__assert_func’
Undefined references to ‘__assert_func’ follow

I’m guessing part of this stems from <assert.h> not getting linked in or found somehow. I’ve tried putting assert.h in the build directory and the source directory. This didn’t work.

I’ve thought about removing the 14 or so references to “assert” in event_temp.c (since this is only called if something is wrong, right?), but I don’t know if there’s a clean way to do this. Also, I’m not sure about how to resolve the __getreent reference (I couldn’t find this anywhere in event_temp).

Any ideas?

Discussion

  • Matt Sottile

    Matt Sottile - 2010-06-02
    • status: open --> closed
     
  • Matt Sottile

    Matt Sottile - 2010-06-02

    Solved based on contents of this email:

    ---

    Hi!

    I don't know the answer off hand as I haven't tried the library with cygwin/mingw in many, many years. A quick search online turns this up though:

    http://lucksus.org/2009/02/12/cygwin-and-undefined-reference-to-__getreent/

    It looks like you may be missing some libraries, like libcygwin.a. Have you tried explicitly adding the -lcygwin argument to the link line (possibly with an accompanying -L argument to make sure the library can be found)?

    That may also fix the assert problem -- it looks like the implementation of both functions (getreent and assert_func) are not being found at link time, and they seem to be part of the cygwin libraries.

    Let me know if that helps. If not, I'll try to reproduce it and dig deeper.

    -matt