G++ compilation, difference between mac os and ubuntu - c++

I have a C++ project looks like the following,
-project/
-include/ --> .hpp files
-src/ --> .cpp files
-bin/ --> for output executable
-makefile
My makefile is the following,
g++ src/* -I include/ -o bin/program
When I run the makefile, it works perfectly on my Mac OS. However I tried to compile it using my Ubuntu and it did not work. I have the following error,
src/SomeFileName.cpp:1:28: fatal error: SomeFileName.hpp: No such file or directory
compilation terminated.
src/main.cpp:1:28: fatal error: SomeFileName.hpp: No such file or directory
compilation terminated.
Should I change some part of the makefile for Ubuntu specifically? What is the problem?
My ubuntu g++ version:
x#x:~$ g++ --version
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
My main.cpp is the following,
#include "ListController.hpp"
#include <time.h>
int main() {
doStuff();
return 0;
}

The only one thing that I can suppose, that on your Mac the PATH environment variable also contains the ./
So, you can try to change your makefile the following way:
g++ ./src/* -I ./include/ -o ./bin/program

Related

I get "gcc.exe: fatal error: cannot execute 'cc1plus'" when I try to compile a program in C++ in Windows

I get the error "gcc.exe: fatal error: cannot execute 'cc1plus'" when I want to compile any program in C++. I didn't installed the compiler Mingw-w64, downloaded the zip from winlibs.com and I copied it to "C:". Then I added to the environment variable Path.
I tried to move the library cc1plus.exe.o to the lib folder of Mingw, and used the commands gcc test.cpp -o test.exe and gcc.exe test.cpp -o text.exe.
The OS is Windows.
Thank you.

Failing to compile GTest with Cygwin

I'm new to C++, I am trying to compile gtest with Cygwin. I have installed the GNU g++ compiler which works fine. I ran the following command on Cygwin:
g++ -I /cygdrive/c/devel/cpp/gtest/include -I /cygdrive/c/devel/cpp/gtest -pthread -c /cygdrive/c/devel/cpp/gtest/googletest/src/gtest-all.cc
/cygdrive/c/devel/cpp/gtest/googletest/src/gtest-all.cc:39:25: fatal error: gtest/gtest.h: No such file or directory
compilation terminated.
All the files seem to be in place, however the error does not go, any ideas why?
It looks like you have provided space between -I and path.
There should not be any space between -I and corresponding path.
It should be like
g++ -I/cygdrive/c/devel/cpp/gtest/include -I/cygdrive/c/devel/cpp/gtes..
Check it.

mingw64 (win8.1) how to let him see boost libs?

I've installed at my win8.1 mingw and I would like to compile my program.
When I use command:
g++ -o test test.cpp -lboost_unit_test_framework-mt
I got an error:
no such file od directory:
"#include boost/test/unit_test.hpp" // in "<>" ofc.
when I use my msVS it works fine.
You also must use the -L and the -I option to specify the directories where the boost libraries and headers are located:
g++ -I<path_to_headers> -o test test.cpp -L<path_to_library> -lboost_unit_test_framework-mt
Note for the headers path that should be the path containing the boost directory.

How do I use the MinGW compiler from the command line on Windows?

I have installed the Bloodshed Dev-C++ compiler on my Windows 7 machine. Now how can I compile from the command line?
File main.cpp:
int main()
{
return 0;
}
Compiling:
g++ -Wall main.cpp -o main
The bin folder from MinGW has to be in the path environment variables, and for g++ there are lots of documentation on how to use it. As far as I know, there is not a difference from g++/MinGW and g++ from Linux, so any Linux tutorial will also work on Windows.

How to add speech.h to g++ in Cygwin?

I'm just trying to compile a c++ program using the emulated g++ compiler in Cygwin on a Windows 7 machine that has the following includes:
iostream
string
windows.h
stdio.h
mmsystem.h
initguid.h
objbase.h
objerror.h
ole2ver.h
speech.h
It compiles them all fine with the exception of speech.h, which is sort of the bread and butter of what I'm working on, soo.. yeah.
Returns the following:
test.cpp:11:20: fatal error: speech.h: No such file or directory compilation terminated.
Any and all help will be much appreciated.
The files that do compile are on your system path, so the compiler can find them. speech.h isn't, so you have to tell it where to look:
g++ -c test.cpp -I<Path_to_speech.h>/speech.h ...
I.e. if it's in C:\Users\Kirk\test\include, then
g++ -c test.cpp -IC:/Users/Kirk/test/include/speech.h ...