# curl-config --libs breaks C++ compilation using GCC 4.8



## interfasys (Jan 21, 2014)

While trying to compile an app which is not in ports, I ran into a problem with what is returned from curl-config --libs. This is what I get
`# curl-config --libs
-L/usr/local/lib -lcurl -lidn -lssl -lcrypto -lssl -lcrypto -L/usr/lib -lgssapi -lheimntlm -lkrb5 -lhx509 -lcom_err -lcrypto -lasn1 -lroken -lcrypt -lz`
The part which causes problems is -L/usr/lib.

If you try to compile a simple C++ example using that output,

```
#include <stdexcept>
#include <string>

  struct bad_day_of_month : public std::out_of_range
  {
    bad_day_of_month() : 
      std::out_of_range(std::string("Day of month value is out of range 1..31")) 
    {}
    //! Allow other classes to throw with unique string for bad day like Feb 29
    bad_day_of_month(const std::string& s) : 
      std::out_of_range(s) 
    {}
  };

int
main() {
	bad_day_of_month b;
	return 0;
}
```
, it will fail.
`# g++48 datetest.cpp -Wall -o datetest `curl-config --libs`
/tmp//ccKintdX.o: In function `bad_day_of_month::~bad_day_of_month()':
datetest.cpp:(.text._ZN16bad_day_of_monthD2Ev[_ZN16bad_day_of_monthD5Ev]+0x1f): undefined reference to `std::out_of_range::~out_of_range()'
collect2: error: ld returned 1 exit status`

If you remove the reference to /usr/lib
`# g++48 datetest.cpp -Wall -o datetest -L/usr/local/lib -lcurl -lidn -lssl -lcrypto -lssl -lcrypto  -lgssapi -lheimntlm -lkrb5 -lhx509 -lcom_err -lcrypto -lasn1 -lroken -lcrypt -lz`
, then it works and all the libraries are properly linked.
`# ldd datetest
datetest:
        libcurl.so.7 => /usr/local/lib/libcurl.so.7 (0x80081b000)
        libidn.so.17 => /usr/local/lib/libidn.so.17 (0x800622000)
        libssl.so.8 => /usr/local/lib/libssl.so.8 (0x800655000)
        libcrypto.so.8 => /usr/local/lib/libcrypto.so.8 (0x800a95000)
        libgssapi.so.10 => /usr/lib/libgssapi.so.10 (0x800ce3000)
        libheimntlm.so.10 => /usr/lib/libheimntlm.so.10 (0x800eed000)
        libkrb5.so.10 => /usr/lib/libkrb5.so.10 (0x8010f2000)
        libhx509.so.10 => /usr/lib/libhx509.so.10 (0x801363000)
        libcom_err.so.5 => /usr/lib/libcom_err.so.5 (0x8015a4000)
        libasn1.so.10 => /usr/lib/libasn1.so.10 (0x8017a6000)
        libroken.so.10 => /usr/lib/libroken.so.10 (0x801a2a000)
        libcrypt.so.5 => /lib/libcrypt.so.5 (0x801c3c000)
        libz.so.6 => /lib/libz.so.6 (0x801e5b000)
        libstdc++.so.6 => /usr/local/lib/gcc48/libstdc++.so.6 (0x80206f000)
        libm.so.5 => /lib/libm.so.5 (0x80238f000)
        libgcc_s.so.1 => /usr/local/lib/gcc48/libgcc_s.so.1 (0x8025b0000)
        libc.so.7 => /lib/libc.so.7 (0x8027c7000)
        libthr.so.3 => /lib/libthr.so.3 (0x802b22000)
        libintl.so.9 => /usr/local/lib/libintl.so.9 (0x8006d2000)
        libiconv.so.3 => /usr/local/lib/libiconv.so.3 (0x8006df000)
        libcrypto.so.6 => /lib/libcrypto.so.6 (0x802d45000)`

So, is there a problem with the curl ports or is my configuration incomplete?
The test came from Phusion, creators of Passenger


----------

