I have some problems linking to GLFW in Netbeans, I have followed the instructions here:
http://forums.netbeans.org/topic51143.html
I have installed Cygwin and MinGW on my computer, I had since earlier an installation of Cygwin, which I tried to use to compile a GLFW program, but I got the same error, so I decided to try MinGW, as per the instructions, still the same problem.
Also, for some reason I can't use msys make.exe as make command, even for compiling a C++ hello world, I have to use the one in Cygwin instead. I have set up windows Path variable to include the locations of both the msys bin directories.
"1) What must be installed (dlls, etc)?
glfw.dll
libgcc_s_dw2-1.dll
libstdc++-6.dll"
I am not sure what this means, does installed in this instance mean that System32/SysWOW64 should contain those mentioned .dlls?
My output for this program (using linker properties as specified here :
http://forums.netbeans.org/topic51143.html)
#include <cstdlib>
#include <stdio.h>
#include <GL/glfw.h>
using namespace std;
int main(int argc, char** argv) {
if (!glfwInit())
return -1;
return 0;
}
Yields:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory /cygdrive/c/Users/sysdba/Documents/NetBeansProjects/GLFW'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW_QT-Windows/glfw.exe
make[2]: Entering directory/cygdrive/c/Users/sysdba/Documents/NetBeansProjects/GLFW'
mkdir -p build/Debug/MinGW_QT-Windows
rm -f build/Debug/MinGW_QT-Windows/main.o.d
g++.exe -lglfwdll -DGLFW_DLL -c -g -Wall -I../../../Downloads/glfw-2.7.7.bin.WIN64/glfw-2.7.7.bin.WIN64/lib-mingw -MMD -MP -MF build/Debug/MinGW_QT-Windows/main.o.d -o build/Debug/MinGW_QT-Windows/main.o main.cpp
g++: -lglfwdll: linker input file unused because linking not done
mkdir -p dist/Debug/MinGW_QT-Windows
g++.exe -lglfwdll -DGLFW_DLL -o dist/Debug/MinGW_QT-Windows/glfw build/Debug/MinGW_QT-Windows/main.o -L../../../../../MinGW/lib -lglfw -lglu32 -lopengl32 -lglfwdll
nbproject/Makefile-Debug.mk:62: recipe for target dist/Debug/MinGW_QT-Windows/glfw.exe' failed
make[2]: Leaving directory/cygdrive/c/Users/sysdba/Documents/NetBeansProjects/GLFW'
nbproject/Makefile-Debug.mk:59: recipe for target .build-conf' failed
make[1]: Leaving directory/cygdrive/c/Users/sysdba/Documents/NetBeansProjects/GLFW'
nbproject/Makefile-impl.mk:39: recipe for target .build-impl' failed
build/Debug/MinGW_QT-Windows/main.o: In functionmain':
/cygdrive/c/Users/sysdba/Documents/NetBeansProjects/GLFW/main.cpp:20: undefined reference to `_imp_glfwInit#0'
collect2: ld returned 1 exit status
make[2]: * [dist/Debug/MinGW_QT-Windows/glfw.exe] Error 1
Any idea of what the problem could be? Could it be related to the fact that I am not using the msys make.exe as make command?
I fixed my MinGW install, so I could use the make.exe in the MinGW msys, instead of the cygwin mysys, did not help.
Not much of an answer, but it seems to be a problem with GLFW somewhere, could not get it to work. I switched to freeglut, Worked like a charm, without any hassle.
Related
I've got Netbeans C/C++ set up, Cygwin installed, configured and running correctly. SDL was installed from the sources using the Cygwin terminal. I've confirmed that Cygwin, Netbeans and SDL are all running correctly, I can write and compile C++ projects just fine with Netbeans and Netbeans can see SDL without having to include any files or anything, it just works like the default libraries.
#include <cstdlib>
#include <sdl2/SDL.h>
using namespace std;
int main(int argc, char** argv) {
return 0;
}
That's the code I'm trying to compile, Netbeans doesn't highlight the include for sdl.h, but when I go to build I get this:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/Cally/Projects/Test'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/test.exe
make[2]: Entering directory '/home/Cally/Projects/Test'
mkdir -p build/Debug/Cygwin_4.x-Windows
rm -f "build/Debug/Cygwin_4.x-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/Cygwin_4.x-Windows/main.o.d" -o build/Debug/Cygwin_4.x-Windows/main.o main.cpp
mkdir -p dist/Debug/Cygwin_4.x-Windows
g++ -o dist/Debug/Cygwin_4.x-Windows/test build/Debug/Cygwin_4.x-Windows/main.o
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39: undefined reference to `WinMain'
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/libcmain.c:39:(.text.startup+0x7e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `WinMain'
collect2: error: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/Cygwin_4.x-Windows/test.exe' failed
make[2]: *** [dist/Debug/Cygwin_4.x-Windows/test.exe] Error 1
make[2]: Leaving directory '/home/Cally/Projects/Test'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/Cally/Projects/Test'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
The build is successful when I don't include SDL. Anybody know what I'm doing wrong?
The error message looks really evil - but it just tells you it can't find a WinMain.
This is a known issue with SDL. Please add those libraries to your linker (order is mandatory!):
mingw32
SDLmain
SDL
You can either add -lmingw32 -lSDLmain -lSDL to linker options or add them through the library menu of linker config.
It's possible you need SDL_mixer too - if so, just add it last.
Please see also: http://content.gpwiki.org/index.php/SDL%3aTutorials%3aSetup
As a "dirty workaround" you can do this: undefine main.
SDL redefines main() as a macro with some additional stuff. You can verify this by egl. Ctrl + click on main / go to declaration / definition or check if it's formatted as makro.
#include <cstdlib>
#include <sdl2/SDL.h>
using namespace std;
/*
* If 'main' is defined we clear that definition
* to get our default 'main' function back.
*/
#ifdef main
# undef main
#endif /* main */
int main(int argc, char** argv) {
return 0;
}
Please see source of SDL_main.h (line 103+).
So I installed Netbeans on windows7 and configured the Ubuntu box with samba to share the developement directory where I have the sources and the boost library.
I compiled the boost library to be able to link to boost_filesystem but I still get this error when I try to compile the application:
Copying project files to /home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/ at nms#ophelia.tele2.net
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/mr_deamon
make[2]: Entering directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915- Windows-x86_64/Z/mr_deamon'
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/mr_deamon.o.d"
g++ -c -g -I/opt/mail-relay/mr_deamon/boost_1_55_0 -I/opt/mail-relay/mr_deamon/mysql_connector_cpp/include -MMD -MP -MF "build/Debug/GNU-Linux-x86/mr_deamon.o.d" -o build/Debug/GNU-Linux-x86/mr_deamon.o mr_deamon.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/mr_deamon build/Debug/GNU-Linux-x86/mr_deamon.o -L/opt/mail-relay/mr_deamon/mysql_connector_cpp/lib -L/opt/mail-relay/mr_deamon/boost_1_55_0/bin.v2/libs -lmysqlcppconn-static -lmysqlclient -lboost_system -lboost_filesystem
build/Debug/GNU-Linux-x86/mr_deamon.o: In function `boost::filesystem::file_size(boost::filesystem::path const&)':
/opt/mail-relay/mr_deamon/boost_1_55_0/boost/filesystem/operations.hpp:447: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
build/Debug/GNU-Linux-x86/mr_deamon.o: In function `path<char*>':
/opt/mail-relay/mr_deamon/boost_1_55_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/mr_deamon] Error 1
make[2]: Leaving directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
I thought I got the linking right.
Here is the program code:
#include <iostream>
#include <boost/filesystem.hpp>
//using namespace std;
using namespace boost::filesystem;
int main(int argc, char**argv)
{
std::cout << file_size(argv[0]);
return EXIT_SUCCESS;
}
The sql part works fine with linking and all, but only including the boost filesystem is enough to get a build error, can't get how to use remote developement with netbeans on windows to Linux. What am I doing wrong?
A new try without netbeans, just on Ubuntu with the example from Boost filesystem link ...
and with compile command:
g++ -pthread mr.cpp -lboost_filesystem-mt -lboost_system-mt
the output is
/tmp/ccIZaqeX.o: In function boost::filesystem::file_size(boost::filesystem::path const&)':
mr.cpp: (.text._ZN5boost10filesystem9file_sizeERKNS0_4pathE[boost::filesystem::file_size(boost::filesystem::path const&)]+0x19): undefined reference toboost::filesystem::detail::file_size(boost::filesystem::path const&, boost::system::error_code*)'
/tmp/ccIZaqeX.o: In function boost::filesystem::path::path<char*>(char* const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<char*>::type>, void>::type*)':
mr.cpp: (.text._ZN5boost10filesystem4pathC2IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x22): undefined reference toboost::filesystem::path::codecvt()'
collect2: ld returned 1 exit status
I don't get it..
I got the same problem just yesterday:
How I solved:
First: if you installed Boost by source, make sure you are compiling it to right compiler toolset that you are using at netbeans. For instance, I tested it with MinGW # Windows 8 Boost/MingW.
Second: In Netbeans (I used 7.4 version), I added the libraries I want by hand:
Project Properties > Linker > Libraries > Add Library > Select the .a
files.
EDIT:
This link maybe be useful: undefined reference with boost when I try to compile
Great, so finally it worked, here is what I did:
1- Installed gcc 4.8 (not sure if this is relevant).
2- downloaded and unpacked boost into /usr/local
3- ran bootstrap.sh
4- modify toolset parameter in project-config.jam into using gcc : 4.8.1 : g++-4.8 ;
5- run ./b2 --with-system
6- run ./b2 --with-filesystem
both step 5 and 6 are done with user root.
7- compile the source file like this:
# g++-4.8 mr.cpp -L /usr/local/boost_1_55_0/stage/lib -I /usr/local/boost_1_55_0 -lboost_system -lboost_filesystem -o mr
Jee, finally, I was few minutes from quitting Boost.
What I think made a difference is the consistency of the compiler (toolset) and the install path, and specially those two "-L /usr/local/boost_1_55_0/stage/lib -I /usr/local/boost_1_55_0"
PROBLEM SOLVED
Go to bottom to see the solution.
Hello everybody i've been googling' looooong time and I didn't find anythinig, so, here we go:
I have this setup:
Compiler: MinGW IDE: Netbeans Library: SDL Language:
C++
Okey, so, i have included this folder: "C:/SDL_1.2.15/include"
And Linked those libraries in this order:
-lmingw32
-lSDL_main
-lSDL
Then if I use a normal program without the #include "SDL/SDL.h" then compiles okeey.
So if i include the SDL header file the IDE gives me greenlight to compile an then, i get this output:
"C:/WinAVR-20090313/utils/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
"C:/WinAVR-20090313/utils/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/sdl_test.exe
make[2]: Entering directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++.exe -c -g -Wall -I/C/MinGW/include -I/C/SDL-1.2.15/include -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
make[2]: Leaving directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
make[1]: Leaving directory `C:/Users/pablo/Documents/NetBeansProjects/SDL_Test'
main.cpp:11:21: error fatal: SDL/SDL.h: No such file or directory
compilaci�n terminada.
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
So! Here is the source code of my application, it only has a 'main.cpp' file:
/*
* File: main.cpp
* Author: pablo
*
* Created on 1 de septiembre de 2013, 23:20
*/
#include <cstdlib>
#include <windows.h>
#include <SDL/SDL.h>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
return 0;
}
I've found new issues; When I remove the #include (comment //) then the console throws me this errors instead the 'no such file or directory':
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lSDLmain
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -lSDL.dll
When I compile without #include using Cygwin compiler, the project builds correctly.
Found another issue:
make[2]: *** No rule to make target `/C/SDL-1.2.15/lib/libSDLmain.a', needed by `dist/Debug/MinGW-Windows/sdl_test.exe'. Stop.
this happens when I add the full path to the SDL libraries instead of -lSDL.dll and -lSDL_main
SOLUTION:
The problem solves coping c:/SDL-1.15/include/SDL/ folder to c:/MinGW/include/ directory, and libraries from lib on c:/SDL-1.15/lib/SDL to MinGW/lib
You have to add the headers separately.
It's not enough to do the include, you have to do multiple things to add a thing like SDL in your project.
I'm trying to make a simple "Hello World!" program in NetBeans IDE 7.3 with MinGW as my C++ compiler.
I'm getting build failures and I'm at a loss as to understanding why.
This is my compiler setup:
Family: MinGW
Base Directory: C:\MinGW
C Compiler: C:\MinGW\bin\gcc.exe
C++ Compiler: C:\MinGW\bin\g++.exe
Assembler: C:\MinGW\bin\as.exe
Make Command: C:\MinGW\msys\1.0\bin\make.exe
Debugger Command: C:\MinGW\bin\gdb.exe
I've made sure to that my environment PATH directs to C:\MinGW\bin and C:\MinGW\msys\1.0\bin.
My code is:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
After trying to build the project, I recieve this message from the NetBeans debug output:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/NetBeansProjects/HelloWorld'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/helloworld.exe
make[2]: Entering directory `/c/NetBeansProjects/HelloWorld'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
make[2]: g++: Command not found
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 127
make[2]: Leaving directory `/c/NetBeansProjects/HelloWorld'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/NetBeansProjects/HelloWorld'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
I've search various Q&A, but I seem to be doing everything correctly.
Right click on My Computer and select properties. Click Advanced System Settings.System Properties dialog box will open. click Environmental Variables. Edit PATH variable and add C:\MinGW\msys\1.0\bin
Your settings on netbeans shoud be as follows
Base Directory: C:\MinGW\bin
C Compiler: C:\MinGW\bin\gcc.exe
C++ Compiler: C:\MinGW\bin\g++.exe
Fortran Compiler: C:\MinGW\bin\gfortran.exe
Assembler: C:\MinGW\bin\as.exe
Make Command: C:\MinGW\msys\1.0\bin\make.exe
Debbuger Command: C:\MinGW\bin\gdb.exe
Add these to your Environment variables
C:\MinGW\bin and C:\MinGW\msys\1.0\bin
This can happen if you have set the settings on netbeans before/during the time of installing MINGW and setting the environment PATH.
Just restart netbeans
you download mysys form mingw or sourceforge.net after install it, path is C:\Mysys\1.0\bin\make.exe to give the path into make compiler in netbean ide.
I'm a total c++ Newbie.
I'm trying to build windows aplications with Wx-Widgets under Net Beans.
So far so good. I have instaled everything, configured, build wx-widgets and attached it to the new project - with help of a good man here: Can't make wx-widget work with net-beans.
Now I try to build my first app:
#include <wx/string.h>
int main(int argc, char **argv)
{
wxPuts(wxT("A wxWidgets console application"));
}
and this is what I get:
I'm not sure if this is readable so I paste the errors:
g++ `C:\WXWIN\wx-config --cxxflags` -c -g -I../../../WXWIN/include `C:\WXWIN\wx-config --cxxflags` -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
/bin/sh.exe: C:WXWINwx-config: command not found
/bin/sh.exe: C:WXWINwx-config: command not found
In file included from ../../../WXWIN/include/wx/defs.h:21:0,
from ../../../WXWIN/include/wx/string.h:25,
from main.cpp:1:
../../../WXWIN/include/wx/platform.h:196:22: fatal error: wx/setup.h: No such file or directory
compilation terminated.
make[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `/c/xampp/htdocs/WxWwigets_tutorial'
make[1]: Leaving directory `/c/xampp/htdocs/WxWwigets_tutorial'
BUILD FAILED (exit value 2, total time: 859ms)
Please notice that I have set everything in linker and compiler like ordered: http://wiki.wxwidgets.org/Compiling_using_Netbeans
The error is right in front of you: "command not found". If you use /bin/sh, you must use Unix style paths, e.g. C:/WXWIN/wx-config instead of DOS paths with the backslashes.
I seriously advise you to get familiar with the environment you're using instead of just following the Wiki instructions without understanding them, otherwise your problems won't be over any time soon.