# compiling libpqxx project error



## Vitamin (Jun 28, 2012)

Hi,

*V*ia the ports tree, I installed the following:

```
postgresql-libpqxx 4.0
postgresql84-client 8.4
```

*T*est code:

```
#include <iostream>
#include <pqxx/pqxx>

using namespace pqxx;
using namespace std;

int main(){

  connection c;

}
```

*C*ompile command:

```
g++ sqlTest.cpp -o sqlT -I /usr/local/include -lpqxx -lpq
```

*E*rror generated

```
/usr/bin/ld: cannot find -lpqxx
```

*A*ny suggestions why are these files not in that folder after installation? *A*ny solutions?

*I*f I tried:

```
g++ sqlTest.cpp -o sqlT -I /usr/local/include
```

*E*rror generated:

```
/var/tmp//ccNEqfUu.o: In function `pqxx::connect_direct::connect_direct(std::string const&)':
proj.cpp:(.text._ZN4pqxx14connect_directC1ERKSs[_ZN4pqxx14connect_directC1ERKSs]+0x19): undefined
 reference to `pqxx::connectionpolicy::connectionpolicy(std::string const&)'
proj.cpp:(.text._ZN4pqxx14connect_directC1ERKSs[_ZN4pqxx14connect_directC1ERKSs]+0x1e): undefined
 reference to `vtable for pqxx::connect_direct'
/var/tmp//ccNEqfUu.o: In function `pqxx::connect_direct::~connect_direct()':
proj.cpp:(.text._ZN4pqxx14connect_directD1Ev[_ZN4pqxx14connect_directD1Ev]+0xd): undefined reference to
 `vtable for pqxx::connect_direct'
proj.cpp:(.text._ZN4pqxx14connect_directD1Ev[_ZN4pqxx14connect_directD1Ev]+0x1d): undefined reference to
 `pqxx::connectionpolicy::~connectionpolicy()'
/var/tmp//ccNEqfUu.o: In function `pqxx::basic_connection<pqxx::connect_direct>::basic_connection()':
proj.cpp:(.text._ZN4pqxx16basic_connectionINS_14connect_directEEC1Ev[_ZN4pqxx16basic_connectionINS_14connect_direc
tEEC1Ev]+0x1d): undefined reference to `pqxx::connection_base::connection_base(pqxx::connectionpolicy&)'
proj.cpp:(.text._ZN4pqxx16basic_connectionINS_14connect_directEEC1Ev[_ZN4pqxx16basic_connectionINS_14connect_direc
tEEC1Ev]+0x51): undefined reference to `pqxx::connection_base::init()'
/var/tmp//ccNEqfUu.o: In function `pqxx::basic_connection<pqxx::connect_direct>::~basic_connection()':
proj.cpp:(.text._ZN4pqxx16basic_connectionINS_14connect_directEED1Ev[_ZN4pqxx16basic_connectionINS_14connect_direc
tEED1Ev]+0x14): undefined reference to `pqxx::connection_base::close()'
```

*A*ny suggestions to a solution?

thank you


----------



## SirDice (Jun 28, 2012)

Not sure but try adding 

```
-L /usr/local/lib
```
to the *g++* command.


----------



## Vitamin (Jun 28, 2012)

*T*hanks for the reply, solution found.

*EDITED*

*I*nstead of this command, which generates an error:
[cmd=]g++ sqlTest.cpp -o sqlT -I /usr/local/include -L /usr/local/lib [/cmd]
I should have also included the suggestion by SirDice, along with the files
[cmd=]g++ sqlTest.cpp -o sqlT -I /usr/local/include -L /usr/local/lib -lpqxx -lpq[/cmd]

The compiler could not find those files because they were in another file, the lib folder. Thanks for the help.


----------

