question about boost asio - c++

i have following code
#include <boost/date_time/posix_time/posix_time.hpp>
#include <iostream>
#include <boost/asio.hpp>
using namespace std;
int main(int argc,char *argv[]) {
boost::asio::io_service io;
boost::asio::deadline_timer t(io,boost::posix_time::seconds(5));
t.wait();
std::cout<<" hello world\n";
return 0;
}
but i have following error list
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/david/NetBeansProjects/Boost'
/usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/boost
make[2]: Entering directory `/home/david/NetBeansProjects/Boost'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/boost build/Debug/GNU-Linux-x86/main.o
build/Debug/GNU-Linux-x86/main.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:205: undefined reference to `boost::system::get_system_category()'
/usr/include/boost/system/error_code.hpp:206: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:211: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:212: undefined reference to `boost::system::get_generic_category()'
/usr/include/boost/system/error_code.hpp:213: undefined reference to `boost::system::get_system_category()'
build/Debug/GNU-Linux-x86/main.o: In function `error_code':
/usr/include/boost/system/error_code.hpp:312: undefined reference to `boost::system::get_system_category()'
build/Debug/GNU-Linux-x86/main.o: In function `boost::asio::error::get_system_category()':
/usr/include/boost/asio/error.hpp:218: undefined reference to `boost::system::get_system_category()'
build/Debug/GNU-Linux-x86/main.o: In function `~posix_thread':
/usr/include/boost/asio/detail/posix_thread.hpp:69: undefined reference to `pthread_detach'
build/Debug/GNU-Linux-x86/main.o: In function `boost::asio::detail::posix_thread::join()':
/usr/include/boost/asio/detail/posix_thread.hpp:77: undefined reference to `pthread_join'
build/Debug/GNU-Linux-x86/main.o: In function `~posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:61: undefined reference to `pthread_key_delete'
build/Debug/GNU-Linux-x86/main.o: In function `posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:47: undefined reference to `pthread_key_create'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/boost] Error 1
make[2]: Leaving directory `/home/david/NetBeansProjects/Boost'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/david/NetBeansProjects/Boost'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 5s)
pleas help what is happaned?

The problem is not in your code, the problem is in the settings of the compiler (actually linker). You need to link to the Boost.System and pthread libraries. Usually it's done by passing -lboost_system, -lpthread to the linker options in your Makefile, or favorite IDE.

You need to link with the Boost.System library: -lboost_system
Also you need to link with pthreads lib: -lpthread

You need to right click your project root folder and select properties.
From there, you need to select 'Linker' in the left pane and the 'Libraries' option field is there. You need to browse your system till you find the libboost_system.a binary. Usually at /usr/local/lib.
If you cant find the file you are after you may not have compiled the source for those libraries yet. Check out either http://ubuntuforums.org/showthread.php?t=1180792 or the getting started documentation included in the boost tar package.

For future reference to anyone with the same problem:
In netbeans right click the project -->Properties -> C++ Compiler and at the bottom there's an option for "Aditional arguments" pass in the -lboost_system option. Note: -lboost_system must be defined or you'll get errors

Related

Add dependencies to C++ project via CMake [duplicate]

I'm trying to use GLFW on a project, but when I compile it, I get a lot of undefined reference errors, while many of them is on the library file (libglfw.a).
I tried both, compile the library and download it, but without success.
I'm using MinGW and MSYS running on Windows 7 32-bits on netbeans. The GLFW version is 2.7.3;
These are the errors:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/prism.exe
make[2]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g++.exe -o dist/Debug/MinGW-Windows/prism build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/ByteBuffer.o -Lexternal -lglfw
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:35: undefined reference to `glMatrixMode#4'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:36: undefined reference to `glLoadIdentity#0'
build/Debug/MinGW-Windows/main.o: In function `Z6renderv':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:56: undefined reference to `glClearColor#16'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:57: undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(window.o):window.c:(.text+0x8ae): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe54): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe6c): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xef6): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf4f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf7f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x174c): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1935): undefined reference to `wglCreateContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x19fe): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1a0e): undefined reference to `wglDeleteContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ea6): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ebc): undefined reference to `glGetFloatv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ed8): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ee7): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1f1a): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1a): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1bf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1ef): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x28b): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x2cf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_glext.o):win32_glext.c:(.text+0x7d): undefined reference to `wglGetProcAddress#4make[2]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
make[1]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/prism.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
CONSTRUIR FALHOU (valor da saída 2, tempo total: 1s)
Don't you have to link the OpenGL libs as well? I don't see libGL or libGLU. I know glClear is in either libGL or libGLU.
In the linker, at Windows, MinGW: -lglew32 -lglfw3 -lopengl32 -lglu32 -lgdi32
Put the libs and the includes files in MinGW and the dlls and exes at Windows systems folders.
In my case the problem was different. I was linking opengl32 in, but still getting the error. The problem turned out to be the library order: glfw has to be linked in before opengl32.
In my case this was in the "Link libraries" listbox in the Code::Blocks IDE, but it's going to be similar in NetBeans or on the command line.
The error I got is
undefined reference to `__imp_glfwInit'
fixed the problem after I change to glfw-3.3.2.bin.WIN64 (64 bit glfw)

linker error, wont compile on Windows but compiles on Mac, Qt but all the libraries are already linked and fine

I'm trying to compile my program, and it already worked on another machine(Mac), I just copied it to a new machine(Windows), because the client wants it for Windows 10, and now it simply won't recognize all of my qtwidgets, it doesn't matters if it find the correct library.
I already check for libraries (qtCore, QtSql, etc) and they are fine and linked, and still get warnings "undefined reference to object", I'll paste what I get from the output window.
I'm using netbeans Qt 5.12.8 on Windows, the program was made on mac Qt 5.11.3
I installed MinGW g++ using the Mkspace win32-g++, its the only mk space that seems to work, but cant go further, I already tried different Qmakes and mkspaces, but it only gets worse.
Program
pantalla_principal.cpp --> https://pastebin.com/jSzwT42s
pantalla_principal.h ---> https://pastebin.com/qH2F4XaG
Login.cpp ---> https://pastebin.com/JDXcrYYe
Login.h ---> https://pastebin.com/e5PsDM5g
ui_Login.h --> https://pastebin.com/7SqX62Pt
ui_Pantalla_Principal.h --> https://pastebin.com/vNByjKgG
output window
cd 'C:\Users\Patron\Desktop\Code Projects\Sistema_Silo'
C:\make-3.81-bin\bin\make.exe -f Makefile CONF=Debug QMAKE=/C/Qt/Qt5.12.8/5.12.8/msvc2015_64/bin/qmake.exe
"/C/make-3.81-bin/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE=/C/Qt/Qt5.12.8/5.12.8/msvc2015_64/bin/qmake.exe SUBPROJECTS= .build-conf
make[1]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
c:/Qt/Qt5.12.8/5.12.8/msvc2015_64/bin/qmake.exe VPATH=. -spec win32-g++ -o qttmp-Debug.mk nbproject/qt-Debug.pro
mv -f qttmp-Debug.mk nbproject/qt-Debug.mk
"c:/make-3.81-bin/bin/make.exe" -f nbproject/qt-Debug.mk dist/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo.exe
make[2]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
g++ -c -fno-keep-inline-dllexport -g -Wall -W -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -Inbproject -I. -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtWidgets -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtGui -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtANGLE -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtSql -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore -I. -I. -I/include -IC:/Qt/Qt5.12.8/5.12.8/msvc2015_64/mkspecs/win32-g++ -o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o Login.cpp
In file included from C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/QVariant:1,
from ui_Login.h:12,
from Login.h:17,
from Login.cpp:14:
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qvariant.h: In constructor 'QVariant::QVariant(QVariant&&)':
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qvariant.h:273:25: warning: implicitly-declared 'constexpr QVariant::Private& QVariant::Private::operator=(const QVariant::Private&)' is deprecated [-Wdeprecated-copy]
273 | { other.d = Private(); }
| ^
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qvariant.h:399:16: note: because 'QVariant::Private' has user-provided 'QVariant::Private::Private(const QVariant::Private&)'
399 | inline Private(const Private &other) Q_DECL_NOTHROW
| ^~~~~~~
windres -i Sistema_Silo_resource.rc -o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo_resource_res.o --include-dir=. -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN
g++ -Wl,-subsystem,windows -mthreads -o dist/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo.exe build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Pantalla_Principal.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/main_Pantalla_Principal.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/moc_Login.o build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/moc_Pantalla_Principal.o C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Widgetsd.a
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Guid.a C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Sqld.a C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libQt5Cored.a build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo_resource_res.o -lmingw32 C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/lib/libqtmaind.a
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o: in function `ZN9EmbarquesC2Ev':
C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:20: undefined reference to `_imp___ZN7QWidgetC2EPS_6QFlagsIN2Qt10WindowTypeEE'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
...
this keeps going for all my qtwidgets so I had to trim it, but it's basically the same warning
...
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Login.o: in function `ZN9Embarques8AprovadoEv':
C:/Qt/Qt5.12.8/5.12.8/msvc2015_64/include/QtCore/qarraydata.h:239: undefined reference to `_imp___ZN10QArrayData10deallocateEPS_jj'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Pantalla_Principal.o: in function `ZN18Pantalla_PrincipalC2Ev':
C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Pantalla_Principal.cpp:31: undefined reference to `_imp___ZN11QMainWindowC2EP7QWidget6QFlagsIN2Qt10WindowTypeEE'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/ui_Pantalla_Principal.h:353: undefined reference to `_imp___ZN8QPalette8setBrushENS_10ColorGroupENS_9ColorRoleERK6QBrush'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/moc_Login.o:moc_Login.cpp:(.rdata$_ZTV9Embarques[__ZTV9Embarques]+0x70): undefined reference to `QWidget::focusInEvent(QFocusEvent*)'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [dist/Debug/msvc_2015_64_qt_5.12.8_win32-g++-Windows/Sistema_Silo.exe] Error 1
make[2]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make[1]: *** [.build-conf] Error 2
make[1]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 26s)
Here is the makefile for this program, its kind of big so I used paste bin, hope it works: https://pastebin.com/Jg9Jz69h
Edit 1: I made my own custom Mkfile in order to point exactly to mingw32-g++ compiler, I set it as a mkspace and I still got the same warnings.
Here is my Output, I had to trim it but its all the same:
cd 'C:\Users\Patron\Desktop\Code Projects\Sistema_Silo'
C:\make-3.81-bin\bin\make.exe -f Makefile CONF=Debug QMAKE=/C/Qt/Qt5.12.8/5.12.8/mingw73_64/bin/qmake.exe
"/C/make-3.81-bin/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE=/C/Qt/Qt5.12.8/5.12.8/mingw73_64/bin/qmake.exe SUBPROJECTS= .build-conf
make[1]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
c:/Qt/Qt5.12.8/5.12.8/mingw73_64/bin/qmake.exe VPATH=. -spec win32-g++-mingw32 -o qttmp-Debug.mk nbproject/qt-Debug.pro
mv -f qttmp-Debug.mk nbproject/qt-Debug.mk
"c:/make-3.81-bin/bin/make.exe" -f nbproject/qt-Debug.mk dist/Debug/MinGW-Windows/Sistema_Silo.exe
make[2]: se ingresa al directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
mingw32-g++ -Wl,-subsystem,windows -mthreads -o dist/Debug/MinGW-Windows/Sistema_Silo.exe build/Debug/MinGW-Windows/Login.o build/Debug/MinGW-Windows/Pantalla_Principal.o build/Debug/MinGW-Windows/main_Pantalla_Principal.o build/Debug/MinGW-Windows/moc_Login.o build/Debug/MinGW-Windows/moc_Pantalla_Principal.o C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Widgetsd.a C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Guid.a C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Sqld.a C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libQt5Cored.a build/Debug/MinGW-Windows/Sistema_Silo_resource_res.o -lmingw32 C:/Qt/Qt5.12.8/5.12.8/mingw73_64/lib/libqtmaind.a -LC:/openssl/lib -LC:/Utils/my_sql/mysql-5.6.11-winx64/lib -LC:/Utils/postgresql/pgsql/lib -lshell32
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/Login.o: in function `ZN9EmbarquesC2Ev':
C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:20: undefined reference to `_imp___ZN7QWidgetC2EPS_6QFlagsIN2Qt10WindowTypeEE'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: C:\Users\Patron\Desktop\Code Projects\Sistema_Silo/Login.cpp:22: undefined reference to `_imp___Z13qFlagLocationPKc'
....
....
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0xf4): undefined reference to `non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0xf8): undefined reference to `non-virtual thunk to QWidget::initPainter(QPainter*) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0xfc): undefined reference to `non-virtual thunk to QWidget::redirected(QPoint*) const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: build/Debug/MinGW-Windows/moc_Pantalla_Principal.o:moc_Pantalla_Principal.cpp:(.rdata$_ZTV18Pantalla_Principal[__ZTV18Pantalla_Principal]+0x100): undefined reference to `non-virtual thunk to QWidget::sharedPainter() const'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(main.o):(.text.startup+0xc0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/Sistema_Silo.exe] Error 1
make[2]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make[1]: *** [.build-conf] Error 2
make[1]: se sale del directorio `C:/Users/Patron/Desktop/Code Projects/Sistema_Silo'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 6s)
Edit 2:
I'm using the make command from Msys seems to work a little better, I still got the undefined reference error but at least doesn't point to errors in the qt files, which it is a linker error anyway.
https://pastebin.com/ZDnCF8zn mkfile
https://pastebin.com/WA34zcrT new makefile for mingw32-g++
Edit 3:
I literally used every compiler installed in my computer, from g++ to mingw g++ and qt g++, also used the makes that comes with qt, got nothing. also installed qt 5.8 just in case an old version can do the trick, nothing.
I need options, I literally ran out of ideas, I even created a brand new project just in case, didn't work.
Edit 4:
I installed QT 5.11.3, and used the Mingw 5.3 32 bits build and it somehow manage to compile partially, let me explain, my issue was it wasn't compiling nor creating no .exe file at all, by using the Qmake qt 5.11.3 it manage to compile but it had several errors
there are missing .dll files, that i had to copy manually (QT5Guid.dll, QT5Core.dll, etc) to the build folder, not big deal
when compiling i get errors from the file qstyleoption.h for basically every single function, just like this
Paste bin --> https://pastebin.com/9rzXR69i
I do get an .exe file but every time I try to run it, I got the warning the application could not be started correctly 0xc00007b, press ok to continue
according to Google that is a problem from Microsoft redistributable c++ (I reinstalled and got the 2015-2019 x64 and x86 versions)
so it was basically a partial win

c++ libtins build error

I'm attempting the litbins build packet example over at http://libtins.github.io.
I've followed the install instructions and am able to #include <tins/tins.h> just fine. The problem seems to be now in actually referencing its functions. When trying to build this class:
#include <tins/tins.h>
#include <cassert>
#include <iostream>
#include <string>
using namespace Tins;
int main() {
NetworkInterface iface = NetworkInterface::default_interface();
NetworkInterface::Info info = iface.addresses();
EthernetII eth("77:22:33:11:ad:ad", info.hw_addr);
eth /= IP("localhost", info.ip_addr);
eth /= TCP(13, 15);
eth /= RawPDU("I'm a payload!");
PacketSender sender;
sender.send(eth, iface);
}
I get this error:
cd '/home/oisin/NetBeansProjects/TCPPacket'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/tcppacket
gmake[2]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
g++ -c -g -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux
g++ -o dist/Debug/GNU-Linux/tcppacket build/Debug/GNU-Linux/main.o
build/Debug/GNU-Linux/main.o: In function `main':
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:26: undefined reference to `Tins::NetworkInterface::default_interface()'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:28: undefined reference to `Tins::NetworkInterface::addresses() const'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:30: undefined reference to `Tins::EthernetII::EthernetII(Tins::HWAddress<6ul, unsigned char> const&, Tins::HWAddress<6ul, unsigned char> const&)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:32: undefined reference to `Tins::IPv4Address::IPv4Address(char const*)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:32: undefined reference to `Tins::IP::IP(Tins::IPv4Address, Tins::IPv4Address)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:34: undefined reference to `Tins::TCP::TCP(unsigned short, unsigned short)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:36: undefined reference to `Tins::RawPDU::RawPDU(std::string const&)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::DEFAULT_TIMEOUT'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::NetworkInterface::NetworkInterface()'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::PacketSender(Tins::NetworkInterface const&, unsigned int, unsigned int)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:40: undefined reference to `Tins::PacketSender::send(Tins::PDU&, Tins::NetworkInterface const&)'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::~PacketSender()'
/home/oisin/NetBeansProjects/TCPPacket/main.cpp:38: undefined reference to `Tins::PacketSender::~PacketSender()'
build/Debug/GNU-Linux/main.o: In function `Tins::EthernetII& Tins::operator/=<Tins::EthernetII>(Tins::EthernetII&, Tins::PDU const&)':
/usr/local/include/tins/pdu.h:537: undefined reference to `Tins::PDU::inner_pdu(Tins::PDU*)'
build/Debug/GNU-Linux/main.o: In function `Tins::EthernetII::~EthernetII()':
/usr/local/include/tins/ethernetII.h:46: undefined reference to `vtable for Tins::EthernetII'
/usr/local/include/tins/ethernetII.h:46: undefined reference to `Tins::PDU::~PDU()'
build/Debug/GNU-Linux/main.o: In function `Tins::IP::~IP()':
/usr/local/include/tins/ip.h:64: undefined reference to `vtable for Tins::IP'
/usr/local/include/tins/ip.h:64: undefined reference to `Tins::PDU::~PDU()'
build/Debug/GNU-Linux/main.o: In function `Tins::TCP::~TCP()':
/usr/local/include/tins/tcp.h:79: undefined reference to `vtable for Tins::TCP'
/usr/local/include/tins/tcp.h:79: undefined reference to `Tins::PDU::~PDU()'
build/Debug/GNU-Linux/main.o: In function `Tins::RawPDU::~RawPDU()':
/usr/local/include/tins/rawpdu.h:64: undefined reference to `vtable for Tins::RawPDU'
/usr/local/include/tins/rawpdu.h:64: undefined reference to `Tins::PDU::~PDU()'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux/tcppacket' failed
gmake[2]: *** [dist/Debug/GNU-Linux/tcppacket] Error 1
gmake[2]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
Netbeans is using c++11 , I've enabled c++11 support with the -DLIBTINS_ENABLE_CXX11=1 and I've run ldconfig along with restarting the VM, same errors.
I've tried linking the class with g++ main.cpp -o main -ltins to get these errors -
In file included from /usr/local/include/tins/tins.h:60:0,
from main.cpp:14:
/usr/local/include/tins/crypto.h:297:13: error: ‘function’ in namespace ‘std’ does not name a type
typedef std::function<void(const std::string&,
^
/usr/local/include/tins/crypto.h:308:13: error: ‘function’ in namespace ‘std’ does not name a type
typedef std::function<void(const std::string&,
^
/usr/local/include/tins/crypto.h:401:44: error: ‘handshake_captured_callback_type’ does not name a type
void handshake_captured_callback(const handshake_captured_callback_type& callback);
^
/usr/local/include/tins/crypto.h:412:34: error: ‘ap_found_callback_type’ does not name a type
void ap_found_callback(const ap_found_callback_type& callback);
^
/usr/local/include/tins/crypto.h:445:9: error: ‘handshake_captured_callback_type’ does not name a type
handshake_captured_callback_type handshake_captured_callback_;
^
/usr/local/include/tins/crypto.h:446:9: error: ‘ap_found_callback_type’ does not name a type
ap_found_callback_type ap_found_callback_;
^
Help appreciated.
EDIT
Following on from dvnguyen's answer below, linking my main.cpp with g++ app.cpp -o app -ltins -std=c++11 solved the above issues, but now I'm left with the following errors -
cd '/home/oisin/NetBeansProjects/TCPPacket'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/tcppacket
gmake[2]: Entering directory '/home/oisin/NetBeansProjects/TCPPacket'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/main.o.d"
g++ -c -g -std=c++11 -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux
g++ -o dist/Debug/GNU-Linux/tcppacket build/Debug/GNU-Linux/main.o -lmain
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lmain
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux/tcppacket' failed
gmake[2]: *** [dist/Debug/GNU-Linux/tcppacket] Error 1
gmake[2]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory '/home/oisin/NetBeansProjects/TCPPacket'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
I'm really clueless as to what I'm missing.
From the undefined reference message in the error log I can tell that you haven't added/linked the lib to your project. I don't know about your Netbean project setting, but if your use gcc, you can see an example here:
g++ app.cpp -o app -ltins -std=c++11

GLFW Undefined References

I'm trying to use GLFW on a project, but when I compile it, I get a lot of undefined reference errors, while many of them is on the library file (libglfw.a).
I tried both, compile the library and download it, but without success.
I'm using MinGW and MSYS running on Windows 7 32-bits on netbeans. The GLFW version is 2.7.3;
These are the errors:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/prism.exe
make[2]: Entering directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-Windows
g++.exe -o dist/Debug/MinGW-Windows/prism build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/ByteBuffer.o -Lexternal -lglfw
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:35: undefined reference to `glMatrixMode#4'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:36: undefined reference to `glLoadIdentity#0'
build/Debug/MinGW-Windows/main.o: In function `Z6renderv':
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:56: undefined reference to `glClearColor#16'
C:\Users\Raphael\Documents\NetBeansProjects\Prism/main.cpp:57: undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(window.o):window.c:(.text+0x8ae): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe54): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xe6c): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xef6): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf4f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0xf7f): undefined reference to `wglGetProcAddress#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x174c): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1935): undefined reference to `wglCreateContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x19fe): undefined reference to `wglMakeCurrent#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1a0e): undefined reference to `wglDeleteContext#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ea6): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ebc): undefined reference to `glGetFloatv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ed8): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1ee7): undefined reference to `glClear#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_window.o):win32_window.c:(.text+0x1f1a): undefined reference to `glClearColor#16'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1a): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1bf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x1ef): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x28b): undefined reference to `glGetString#4'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(glext.o):glext.c:(.text+0x2cf): undefined reference to `glGetIntegerv#8'
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libglfw.a(win32_glext.o):win32_glext.c:(.text+0x7d): undefined reference to `wglGetProcAddress#4make[2]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
make[1]: Leaving directory `/c/Users/Raphael/Documents/NetBeansProjects/Prism'
'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/prism.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
CONSTRUIR FALHOU (valor da saída 2, tempo total: 1s)
Don't you have to link the OpenGL libs as well? I don't see libGL or libGLU. I know glClear is in either libGL or libGLU.
In the linker, at Windows, MinGW: -lglew32 -lglfw3 -lopengl32 -lglu32 -lgdi32
Put the libs and the includes files in MinGW and the dlls and exes at Windows systems folders.
In my case the problem was different. I was linking opengl32 in, but still getting the error. The problem turned out to be the library order: glfw has to be linked in before opengl32.
In my case this was in the "Link libraries" listbox in the Code::Blocks IDE, but it's going to be similar in NetBeans or on the command line.
The error I got is
undefined reference to `__imp_glfwInit'
fixed the problem after I change to glfw-3.3.2.bin.WIN64 (64 bit glfw)

Can't compile libpqxx tests using Netbeans

I'm trying to compile a very simple program that makes a connection to a database and prints the database name. I'm able to compile on the command line but am unable to do so in Netbeans. I'm using Netbeans IDE 6.9.1 on Ubuntu 10.04 and am using g++ 4.4.3 and libpqxx 2.6.9 installed using apt-get. Code follows:
#include <iostream>
#include <pqxx/connection>
using namespace std;
using namespace pqxx;
int main(int argc, char *argv[])
{
try
{
// Set up a connection to the backend
connection C(argv[1]);
cout << C.dbname() << endl;
}
catch (const exception &e)
{
// All exceptions thrown by libpqxx are derived from std::exception
cerr << "Exception: " << e.what() << endl;
return 2;
}
return 0;
}
I can successfully compile using the following:
g++ -g -o example -L/usr/lib/ -lpqxx -lpq dbtest001.cpp
Netbeans fails with this:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/dev/work/cpptest'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cpptest
make[2]: Entering directory `/home/dev/work/cpptest'
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/cpptest build/Debug/GNU-Linux-x86/main.o
make[2]: Leaving directory `/home/dev/work/cpptest'
make[1]: Leaving directory `/home/dev/work/cpptest'
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/dev/work/cpptest/main.cpp:13: undefined reference to `pqxx::connection_base::dbname()'
build/Debug/GNU-Linux-x86/main.o: In function `connect_direct':
/usr/include/pqxx/connection.hxx:84: undefined reference to `pqxx::connectionpolicy::connectionpolicy(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/include/pqxx/connection.hxx:84: undefined reference to `vtable for pqxx::connect_direct'
build/Debug/GNU-Linux-x86/main.o: In function `~connect_direct':
/usr/include/pqxx/connection.hxx:82: undefined reference to `vtable for pqxx::connect_direct'
/usr/include/pqxx/connection.hxx:82: undefined reference to `pqxx::connectionpolicy::~connectionpolicy()'
build/Debug/GNU-Linux-x86/main.o: In function `basic_connection':
/usr/include/pqxx/basic_connection.hxx:61: undefined reference to `pqxx::connection_base::connection_base(pqxx::connectionpolicy&)'
/usr/include/pqxx/basic_connection.hxx:62: undefined reference to `pqxx::connection_base::init()'
build/Debug/GNU-Linux-x86/main.o: In function `~basic_connection':
/usr/include/pqxx/basic_connection.hxx:70: undefined reference to `pqxx::connection_base::close()'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/cpptest] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 622ms)
Can anyone offer any insight into why this is failing? I've been away from C++ for a while so am not as sharp at working out where things have gone wrong as I used to be.
g++ -o dist/Debug/GNU-Linux-x86/cpptest build/Debug/GNU-Linux-x86/main.o
You'll notice that Netbeans hasn't added the -L and -l options to the linker command like you did. This is causing the 'undefined reference' errors -- it's not linking your program to the pqxx library.
You'll need to edit your Netbeans project to set up the proper library path and dependencies.
I am also new to Netbeans, this picture might help others as well.