Using gcc with Netbeans - c++

I want to learn to use shaders and therefore created a new C++ project on Netbeans (ver. 8.0.2).
I want to include the GLFW and the GLEW Library like stated in this tutorial: http://www.learnopengl.com/#!Getting-started/Creating-a-window
I think i included the librarys successfully. (Netbeans shows no error when using #include <GL\glew.h> or #include <GLFW\glfw3.h>, so i think it finds all the files).
My System: Windows 10 x64, using GNU gcc compiler via cygwin
Now here is the problem:
When i try to run the program, there is the following output:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/finallyshaders.exe
make[2]: Entering directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
mkdir -p build/Debug/Cygwin-Windows
rm -f "build/Debug/Cygwin-Windows/main.o.d"
gcc -c -g -include /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL -include /cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/GLFW -MMD -MP -MF "build/Debug/Cygwin-Windows/main.o.d" -o build/Debug/Cygwin-Windows/main.o main.c
cc1: fatal error: /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL: No such file or directory
compilation terminated.
nbproject/Makefile-Debug.mk:66: recipe for target 'build/Debug/Cygwin-Windows/main.o' failed
make[2]: *** [build/Debug/Cygwin-Windows/main.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/Erik/programming/projects/FinallyShaders'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 722ms)
It seems to fail because the gcc compiler (or more precisely the cc1 part of it) can't find the include-directory for the library. But, as stated, the path is correct. When using cd <the path that cannot be found> everything works and cygwin finds this path.
(My program does nothing but calling printf() until now, that shouldn't be the problem)
Does anybody know what this could mean and how to solve this?
Thanks for your help
Erik Brendel

Your failing compiler commandline is:
gcc -c -g \
-include /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL \
-include /cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/GLFW \
-MMD -MP -MF "build/Debug/Cygwin-Windows/main.o.d" \
-o build/Debug/Cygwin-Windows/main.o main.c
To fix the reported error:
cc1: fatal error: /cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL: No such file or directory
it should be:
gcc -c -g \
-I/cygdrive/C/Users/Erik/programming/Libraries/glew-1.13.0-win32/glew-1.13.0/include/GL \
-I/cygdrive/C/Users/Erik/programming/Libraries/glfw-3.1.2.bin.WIN32/glfw-3.1.2.bin.WIN32/include/GLFW \
-MMD -MP -MF "build/Debug/Cygwin-Windows/main.o.d" \
-o build/Debug/Cygwin-Windows/main.o main.c
You have confused the compiler options -include and -I. See the documentation of
these options
Here is a pretty good introductory tutorial to the use of GCC
In the Netbeans project properties, the include search-directories should be
entered in Build -> C Compiler -> Include Directories, not Include Headers.

Are you configuring the proyect linker for Netbeans?? This means telling the IDE you will be using libraries that are not added by default with just the include command, for example the math.h library(remember you had to compile with -lm via command promp, it's the same thing).
This can be done by going to run-proyect configuration-customize-Linker-Libraries(you click on the button with says ...).
Then you click on add pkgconfig library or standard(for something like math.h or pthread in unix systems), and search for the library you wish to add.

Related

Build Fail arm-none-eabi-gcc

I got into the book "Beginning STM32" - Warren Gay.
I tried to build the sources under Cygwin, but even if the path to the required files is denoted in the makefile, the required files were not found.The file in the folders libopencm3/cm3/scb.h lays in the path: /home/root/STM32/stm32f103c8t6/libopencm3/include so the correct path should be /home/root/STM32/stm32f103c8t6/libopencm3/include/libopencm3/cm3/scb.h and I checked the presence of the files.
So I tried to change the #include into #include "file.h" with the required header file in the source folder - this worked, but there are a lot of cases in different source files.
Is there any suggestion to get this fixed or to find a way to get out of this?
Thanks a lot!
This is what I got from the terminal.
[~/STM32/stm32f103c8t6]
$ make
make -C rtos/libwwg
make[1]: Entering directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg'
make -w -C ./src
make[2]: Entering directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg/src'
arm-none-eabi-gcc -Os -g -std=c99 -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd -Wextra -Wshadow -Wimplicit-function-declaration -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -fno-common -ffunction-sections -fdata-sections -I/home/root/STM32/stm32f103c8t6/libopencm3/include -I/home/root/STM32/stm32f103c8t6//rtos/libwwg/include -I./rtos -I. -MD -Wall -Wundef -DSTM32F1 -I/home/root/STM32/stm32f103c8t6/libopencm3/include -I/home/root/STM32/stm32f103c8t6//rtos/libwwg/include -o usbcdc.o -c usbcdc.c
usbcdc.c:7:10: fatal error: libopencm3/cm3/scb.h: No such file or directory
7 | #include <libopencm3/cm3/scb.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [../../../Makefile.incl:111: usbcdc.o] Error 1
make[2]: Leaving directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg/src'
make[1]: *** [Makefile:8: all] Error 2
make[1]: Leaving directory '/home/root/STM32/stm32f103c8t6/rtos/libwwg'
make: *** [Makefile:41: libwwg] Error 2
So, I know what is the source of the problem.
There are problems in Cygwin with the path format or rather between the interaction between the Windows and Linux path formats. I could solve the problem by changing the paths in the Makefile from the Linux /home/folder to the Windows D:\home\folder\ format.
more detailed answer beginners:
modifying 2 lines at "Makefile.incl" may solve the problem.
"Makefile.incl" is suppose to be in ~/STM32/stm32f103c8t6 folder in above case.
Following are the lines in "Makefile.incl"
#TOP_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TOP_DIR := C:\xyz\home\STM32\stm32f103c8t6
#OPENCM3_DIR := $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/libopencm3)
OPENCM3_DIR := c:/xyz/home/STM32/stm32f103c8t6/libopencm3
'\' or '/' in path doesn't matter

I don't understand GNU g++ compiler error "cc1plus: fatal error: ..."

I'm in the final stages (I hope) of porting an old Windows XP C/C++ program to LINUX. I edited and tested a C++ class in the file DateTime.cpp. In my test project it worked so I applied the edits to my working project. When I make the project I get an error that I don't understand:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/programmer/NetBeansProjects/Flight4'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/flight4
make[2]: Entering directory `/home/programmer/NetBeansProjects/Flight4'
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/DateTime.o.d"
g++ -ffreestanding -c -include /usr/local/include -MMD -MP -MF "build/Debug/GNU-Linux-x86/DateTime.o.d" -o build/Debug/GNU-Linux-x86/DateTime.o DateTime.cpp
cc1plus: fatal error: /usr/local/include: No such file or directory
compilation terminated.
/usr/local/include exists; DateTime.cpp and DateTime.hpp are in the local project directory
/home/programmer/NetBeansProjects/Flight4
The project uses a couple of .so libraries in /usr/local/lib with their header files in /usr/local/include.
I've not coded in C/C++ for about 5 years now and when I did I used a RAD so I'm not skilled with makefiles.
Edit: Etan's comment was right on the button: I had added /usr/local/bin to the wrong spot in the properties wizard. Moving it to the correct field in the NetBeans Properties wizard fixed the problem.

How can I connect modules?

So, I am trying to write Makefile.am that will check the source code and the dependencies for the build.
configure.in
AC_PREREQ([2.68])
AC_INIT([hello], [1.0], [basinbug at yahoo.com])
AC_CONFIG_SRCDIR([src/hello.cpp])
AM_INIT_AUTOMAKE
AC_PROG_CXX
PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.10])
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
src/Makefile.am
bin_PROGRAMS = hello
hello_CFLAGS = $(GTK_CFLAGS)
hello_LDFLAGS = $(GTK_LIBS)
hello_SOURCES = hello.cpp
what happens when i run "make"
Making all in src
make[1]: Entering directory `/home/maza/123/src'
g++ -DPACKAGE_NAME=\"hello\" -DPACKAGE_TARNAME=\"hello\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"hello\ 1.0\" -DPACKAGE_BUGREPORT=\"basinbug\ at\ yahoo.com\" -DPACKAGE_URL=\"\" -DPACKAGE=\"hello\" -DVERSION=\"1.0\" -I. -g -O2 -MT hello.o -MD -MP -MF .deps/hello.Tpo -c -o hello.o hello.cpp
hello.cpp:2:21: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
make[1]: *** [hello.o] Error 1
make[1]: Leaving directory `/home/maza/123/src'
make: *** [all-recursive] Error 1
If I'm going as AC_PROG_CC, they are used for compile the string, through AC_PROG_CXX it is not used
You are telling the autotools that your project is a C++ project (with AC_PROG_CXX) but you are then setting a C flag variable (hello_CFLAGS).
The matching variable for C++ is hello_CXXFLAGS.
That being said neither of those is the correct flag to use for this usage. The correct flag (thanks ptomato) is hello_CPPFLAGS.

GLFW Can't compile example netbeans mingw w64

I used the precompiled version of GLFW for windows. I use netbeans and i can't resolve this error.
"/E/Develop/Util/msys/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/e/Develop/Project/Netbeans/C++/CppApplication_1'
"/E/Develop/Util/msys/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-w64_x64_-posix-seh-Windows/cppapplication_1.exe
make.exe[2]: Entering directory `/e/Develop/Project/Netbeans/C++/CppApplication_1'
mkdir -p build/Debug/MinGW-w64_x64_-posix-seh-Windows
rm -f "build/Debug/MinGW-w64_x64_-posix-seh-Windows/main.o.d"
g++ -c -g -I/E/Develop/Library/C++/GLFW\ 3.0.4/include -MMD -MP -MF "build/Debug/MinGW-w64_x64_-posix-seh-Windows/main.o.d" -o build/Debug/MinGW-w64_x64_-posix-seh-Windows/main.o main.cpp
mkdir -p dist/Debug/MinGW-w64_x64_-posix-seh-Windows
g++ -o dist/Debug/MinGW-w64_x64_-posix-seh-Windows/cppapplication_1 build/Debug/MinGW-w64_x64_-posix-seh-Windows/main.o -L../../../../Library/C++/GLFW\ 3.0.4/lib-mingw -L../../../../Compiler/C++/MinGW-w64\(x64\)-posix-seh/x86_64-w64-mingw32/lib -lglfw3 -lglfw3dll
e:/Develop/Compiler/C++/MinGW-w64(x64)-posix-seh/bin/../lib/gcc/x86_64-w64-mingw32/4.9.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lglfw3dll
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-w64_x64_-posix-seh-Windows/cppapplication_1.exe] Error 1
make.exe[2]: Leaving directory `/e/Develop/Project/Netbeans/C++/CppApplication_1'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/e/Develop/Project/Netbeans/C++/CppApplication_1' make.exe": *** [.build-impl] Error 2
i add the directory and linked the Libraries like this
this is the code
how can i fix this?
The GLFW has two versions of libraries - static and dynamic (DLL). If you want to link with the static library, then you won't have to include the glfw3dll (which is a DLL link library) into the list of libraries. Please see the Building programs that use GLFW for more info. They also mention other libraries you need to link to.

netbeans mysql connector No such file or directory (MinGW)

i try to link mysql-connector 1.1.3 in Netbeans (7.3, Windows 7) with Mingw-Compiler to my c++ Project.
In the project properties i have add all mysql-connector directories (include, lib, cppcon) under "included Directorys" and under Linker "Additionell Linker Directorys". I added the boost libs to.
But in the Compiler Output say always:
fatal error: mysql_connection.h: No such file or directory
Sorry for my poor english and thanks for help...
the complete output:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory /cygdrive/c/Users/Toni/Desktop/dev/Wiesel/new/tests/sql_test2'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/sql_test2.exe
make[2]: Entering directory/cygdrive/c/Users/Toni/Desktop/dev/Wiesel/new/tests/sql_test2'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -I/D/libs/mysql-connector-c++-noinstall-1.1.3-win32 -I/D/libs/mysql-connector-c++-noinstall-1.1.3-win32/include -I/D/libs/mysql-connector-c++-noinstall-1.1.3-win32/include/cppconn -I/D/libs/mysql-connector-c++-noinstall-1.1.3-win32/lib -I/D/libs/boost_1_53_0 -I/D/libs/boost_1_53_0/boost -I/D/libs/boost_1_53_0/libs -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
main.cpp:9:30: fatal error: mysql_connection.h: No such file or directory
compilation terminated.
nbproject/Makefile-Debug.mk:66: recipe for target build/Debug/MinGW-Windows/main.o' failed
make[2]: [build/Debug/MinGW-Windows/main.o] Error 1 (ignored)
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/sql_test2 build/Debug/MinGW-Windows/main.o -L/D/libs/boost_1_53_0/boost -L/D/libs/boost_1_53_0/libs -L/D/libs/mysql-connector-c++-noinstall-1.1.3-win32 -L/D/libs/mysql-connector-c++-noinstall-1.1.3-win32/include -L/D/libs/mysql-connector-c++-noinstall-1.1.3-win32/include/cppconn -L/D/libs/mysql-connector-c++-noinstall-1.1.3-win32/lib -lmysqlcppconn -lmysqlcppconn-static -lmysqlcppconn -static
g++.exe: error: build/Debug/MinGW-Windows/main.o: No such file or directory
nbproject/Makefile-Debug.mk:62: recipe for targetdist/Debug/MinGW-Windows/sql_test2.exe' failed
make[2]: [dist/Debug/MinGW-Windows/sql_test2.exe] Error 1 (ignored)
make[2]: Leaving directory /cygdrive/c/Users/Toni/Desktop/dev/Wiesel/new/tests/sql_test2'
make[1]: Leaving directory/cygdrive/c/Users/Toni/Desktop/dev/Wiesel/new/tests/sql_test2'
This should be what you're looking for:
A library would normally reside in its own installation directory so you would need to point NB to where that is. If you right-click the project name in the "Projects" window, you'll have a Properties option.
Select the Build/C++ compiler option to add the directory for the .h files.
Select the Build/Linker to add the directory for the dll file.
Include C++ library in Netbeans 7.0