Different GCC version in eclipse, what should I set? - c++

I have installed the latest gcc version, without overwriting the existing one, so now I have two differents gcc versions installed. My question is how do I set eclipse CDT (luna version) to use such version? I've tried by setting in project, properties, C/C++ Build environment and changing the path variable, but it doesn't work.
Specifically the problem I have is:
make all
Building file: ../main.cc
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cc"
g++: error trying to exec 'as': execvp: No such file or directory
make: *** [main.o] Error 1
I changed the path variable to point to the binaries of the the gcc version i've installed.
More Info:
The OS is Red Hat

Please check if you have set the "PATH" in "Environment Variables" correctly
("My Computer -> Properties ->Advanced Settings -> Environment Variables").
Open a cmd prompt and type
echo %PATH%
Verify if the required compiler path is set correctly.
Now restart the Eclipse Luna to get the changes fetched. (Sometimes a system restart is also required)

Related

C++ CodeBlocks and wxWidgets file not found?

I'm pretty new to C::B and just installed it along with building wxWidgets. I'm pretty sure my wxWidgets build with MinGW is good, i was able to successfully create a wxWidgets project in C::B using the "minimal.cpp" sample in wxWidgets. However now instead of creating an empty project, I'm using leaving "Empty project" unchecked in wizard to create the program. With wxWidgets this creates 2 source files and 2 header files (for app and main). When I try to build+play the project though without making any changes i get this error:
-------------- Build: Debug in MULLSIMPLE (compiler: GNU GCC Compiler)---------------
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -c "C:\Users\gmloo\OneDrive\Desktop\C++ Projects\MULLSIMPLE\wx_pch.h" -o wx_pch.h.gch\Debug_wx_pch_h_gch
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -c "C:\Users\gmloo\OneDrive\Desktop\C++ Projects\MULLSIMPLE\MULLSIMPLEApp.cpp" -o obj\Debug\MULLSIMPLEApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -D__WXDEBUG__ -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -c "C:\Users\gmloo\OneDrive\Desktop\C++ Projects\MULLSIMPLE\MULLSIMPLEMain.cpp" -o obj\Debug\MULLSIMPLEMain.o
windres.exe -I"C:\Program Files\wxWidgets-3.0.5\include" -I"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll\mswud" -J rc -O coff -i C:\Users\gmloo\OneDrive\Desktop\C__PRO~1\MULLSI~1\resource.rc -o obj\Debug\resource.res
g++.exe -L"C:\Program Files\wxWidgets-3.0.5\lib\gcc_dll" -o bin\Debug\MULLSIMPLE.exe obj\Debug\MULLSIMPLEApp.o obj\Debug\MULLSIMPLEMain.o obj\Debug\resource.res -mthreads -lwxmsw30ud_core -lwxbase30ud -lwxpngd -lwxzlibd -mwindows
gcc: error: Files\wxWidgets-3.0.5\include: No such file or directory
gcc: error: Files\wxWidgets-3.0.5\lib\gcc_dll\mswud: No such file or directory
windres.exe: preprocessing failed.
Process terminated with status 1 (0 minute(s), 14 second(s))
Process terminated with status 0 (0 minute(s), 16 second(s))
3 error(s), 0 warning(s) (0 minute(s), 16 second(s))
Saying that it can't find files? the wxWidgets-3.0.5 is actually in c:\Program Files/wxWidgets-3.0.5, so maybe its looking in the wrong place? Or maybe I missed a step setting it up?
This is absolutely everything I did to install C::B, install wxWidgets, and create my project
1. Installing CodeBlocks
a. Clicked codeblocks-20.03mingw-setup.exe from website, then download started automaticallty from fosshub
b. Ran executable to install and for type of install did "All plugins, all tools, just everything"
-all checkboxes were checked, including
1. Default Install
2. Contrib Plugins
3. C::B CBP2Make
4. C::B Share Config
5. C::B Launcher
6. MinGW Compiler Suite
2. Downloading wxWidgets
a. Clicked "Windows ZIP" from downloads page on website under "Latest Stable Release: 3.0.5"
b. Extracted download to c:\Program Files\wxWidgets-3.0.5
-first file asked for administrator permission, i said "dont ask again" and clicked "continue"
3. Added MinGW to path
a. went into c:\Program Files\CodeBlocks\MinGW\bin and copied that path to PATH environment variables
4. Building wxWidgets
a. opened a terminal with admin privileges and went to c:\Program Files\wxWidgets-3.0.5\build\msw.
b. entered commands as suggested at https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW, except changed
BUILD=release to BUILD=debug:
1. mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug clean
2. mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug
c. wxWidgets successfully built (3:38 pm to 4:22pm!)
5. Opened CodeBlocks
a. got message that "After auto-detection, at least one compiler's master path is still empty and therefore invalid.
Inspect the list below and change the compiler's master path later in the compiler options. Select you favourite
default compiler here:"
-There's one compiler listed as detected: GNU GCC Compiler
-With this compiler highlighted, i clicked "Set as default" and then ok.
b. got message CodeBlocks is not default app for C/C++ source files.
-Selected "Yes, associate with C/C++ files"
7. Testing Compiler
-I wasn't sure what to do about "setting compiler master path..." msg earlier, so I just created a new project with type
"Console application", compiled the basic "Hello world" application, ran it, ran fine, so I assume compiler is working?
6. Create new wxWidgets program:
a. Create new project: wxWidgets project
b. Wizard Steps:
PAGE 1:
-Set version: wxWidgets 3.0.x
PAGE 2:
-Named project "MULLSIMPLE" and created directory
PAGE 3:
-Skipped Author info.
PAGE 4:
-Preferred GUI Builder: None
-Application Type: Frame Based
PAGE 5:
-wxWidgets location: C:\Program Files\wxWidgets-3.0.5
-When I hit next, it opens the global variable editor. I don't know how to use this,
so i just hit ok without making any changes. IT asked if i want to save an invalid global var,
i said yes. Now the widgets location in the wizard is a path instead of a global variable,
I assume this is ok for now
PAGE 6:
-By default "Debug" configuration checked, "Release" configuration is unchecked
-make no changes
PAGE 7:
-Under wxWidgets library settings:
-CHECK Use wxWidgets DLL
-UNCHECK wxWidgets built as monolithic
-CHECK enable unicode
-Under Miscellaneous settings:
-UNCHECK create empty project
-CHECK create and use PCH
-Leave configuration input field blank
-UNCHECK Configure Advanced Options
-On next get dialog re PCH default settings, click YES to accept
PAGE 8:
-Didn't select any additional libs to add to project,
just hit finish
8. Try Build and run
-Get the build log error at start of post re: missing files
Thanks
#user4581301 thanks for your response it looks like that was the problem. I copied the wxWidgets-3.0.5 to the desktop. Then i opened up the old one in prog files, cleaned the build, then deleted that folder. Then i created a new C::B proj using the wxWidgets path to the one on the desktop, and now the error is gone.
I don't 100% understand how wxWidgets works so I hope just copying the whole folder to another location is fine, but so far program seems to be working. Thanks

I am trying to build a single c++ project in Eclipse but getting the build error even if after setting the path variable with mingw path

When click the buildall option in eclipse I am facing below error and object file is not getting created
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -osrc\helloworld.o ..\src\helloworld.cpp
Internal Builder: Cannot run program "g++"
Put complete path of c++ compiler present in the mingw, in the enviroment variable of eclipse. Then close the IDE and restart it .

Clang/LLVM on Eclipse (Mac)

I am trying to run Eclipse with the Clang compiler without success. First I went here http://clang.llvm.org/get_started.html and followed the instructions 1 through 8 successfully. I also installed the llvm toolchain via Eclipse marketplace.
What do I do next to successfully compile with Clang? From the installation I have two folders, llvm and build, where do I put them? How do I connect this to Eclipse?
I also downloaded lld in case I needed it since the llvm-ld doesn't work anymore. Below is my error message. I'll be so grateful if someone can help me figure this out! I've wasted a lot of hours on this.
20:09:47 **** Incremental Build of configuration Debug for project recursion ****
Info: Internal Builder is used for build
clang -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -o recursiveprint.bc ../recursiveprint.c
lld -v -native -o recursion recursiveprint.bc
Cannot run program "lld": Unknown reason
Error: Program "lld" not found in PATH
PATH=[/usr/bin:/bin:/usr/sbin:/sbin]
20:09:47 Build Finished (took 74ms)

Configure Eclipse CDT to use g++

I have cygwin installed, and I want to use Eclipse with CDT for development under Windows 7. However, I get following error:
**** Build of configuration Default for project hello_cpp ****
make all
g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp
process_begin: CreateProcess(C:\cygwin\bin\g++.exe, g++ -O2 -g -Wall -fmessage-length=0 -c -o hello_cpp.o hello_cpp.cpp, ...) failed.
make (e=5): Access denied.
make: *** [hello_cpp.o] Error 5
**** Build Finished ****
I'm able to use g++ as standalone compiler.
cygwin /bin folder is
added to path.
After googling I found out that C:\cygwin\bin\g++.exe is a cygwin symbolic link and Windows doesn't understand it and I need to point to the g++-3 location directly. How do I do it?
I think you've done something wrong and need to start over again. Just installed Cygwin and Eclipse CDT (Indigo) on my Windows 7 and all works fine and auto-magicaly for me.
Here's what I did and I think you need to do:
Get the latest Cygwin (yes, get it again! get rid of the old one just to be sure)
During the installation make sure to select gcc, gcc-g++ and make (I additionally installed couple of other things like gcc4, w32api but it's optional)
Start Cygwin terminal to init all configuration files, etc. See if g++ executes and close the terminal.
Add C:\cygwin\bin (or wherever else you installed it) to your Environment PATH variable
Get Eclipse CDT, extract it somewhere and start it up.
Go to File -> New Project -> C++ Project and select Hello World C++ Project. You should see the Cygwin GCC in the Toolchains list.
Create the Project, build and run it!
Done!
Build output:
**** Build of configuration Debug for project TestApp ****
make all
Building file: ../src/TestApp.cpp
Invoking: Cygwin C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/TestApp.d" -MT"src/TestApp.d" -o "src/TestApp.o" "../src/TestApp.cpp"
Finished building: ../src/TestApp.cpp
Building target: TestApp.exe
Invoking: Cygwin C++ Linker
g++ -o "TestApp.exe" ./src/TestApp.o
Finished building target: TestApp.exe
**** Build Finished ****
You can go to
Project Properties Page > C / C++ Build > Settings > Tool Settings
And change the command as you want. Documentation here.
Refer this link, it shows how to setup eclipse for native development with ease. everything is done in eclipse except setting environment variables.

Missing Python.h while trying to compile a C extension module

I'm following this tutorial on how to extend Python with C\C++ code.
The section named "Building the extension module with GCC for Microsoft Windows" fails for me with the following error:
fatal error: Python.h: No such file or directory
The section named "Building the extension module using Microsoft Visual C++" also fails with a similar error:
fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
What should I do to solve this?
For Linux, Ubuntu users to resolve the issue of missing Python.h while compiling, simply run the following command in your terminal to install the development package of python:
In Terminal: sudo apt-get install python-dev
Good luck
Do you have the python dev files so that you can find Python.h?
Do you have the location of Python.h specified to your compiler? with gcc this is usually done through a -I path to include.
Figuring out which of those is failing will solve your problem.
from the article you linked:
gcc -c hellomodule.c -I/PythonXY/include
gcc -shared hellomodule.o -L/PythonXY/libs -lpythonXY -o hello.dll
They assumed you installed python in the default location c:\pythonXY(Where X is the major version number and Y is the minor version number).(in your case Python26) If you put python somewhere else replace /PythonXY with where ever you installed it.
The Python official documentation has already made it clear. Check it out here
The header files are typically installed with Python. On Unix, these are located in the directories prefix/include/pythonversion/ and exec_prefix/include/pythonversion/, where prefix and exec_prefix are defined by the corresponding parameters to Python’s configure script and version is '%d.%d' % sys.version_info[:2]. On Windows, the headers are installed in prefix/include, where prefix is the installation directory specified to the installer.
To include the headers, place both directories (if different) on your compiler’s search path for includes. Do not place the parent directories on the search path and then use #include ; this will break on multi-platform builds since the platform independent headers under prefix include the platform specific headers from exec_prefix.
And they have provided a convenient way to get the correct cflags that we should pass to compiler. here
So for example, here is what I got after running the command
root#36fd2072c90a:/# /usr/bin/python3-config --cflags
-I/usr/include/python3.5m -I/usr/include/python3.5m -Wno-unused-result -Wsign-compare -g -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
Pass those flags to the compiler, and it will work.