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

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 ...

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.

How do I link the static Stasm library to my program?

Earlier I succesfully compiled Stasm using cmake on Ubuntu 13.10. It gave me the static library libstasm.a.
However, I'm trying to build my own program using Stasm code but every time I try g++ gives me this:
hanna#hanna-HP-650-Notebook-PC:~/Desktop$ g++ -Wall -L/home/hanna/Downloads/stasm4.1.0/build -lstasm stasmtest.cpp -o stasmtest
stasmtest.cpp:7:23: fatal error: stasm_lib.h: No such file or directory
#include "stasm_lib.h"
^
compilation terminated.
I tried compiling the Minimal.cpp example in the external library because that is supposed to show how to use Stasm in my own programs but still I get the same error.
Can someone please tell me what command I should use to link the Stasm library to my program?
Thanks in advance!
You get a compilation error, not a linking one. g++ cannot find the "stasm_lib.h" header. Use -I/path/to/stasm_lib.h as parameter to g++.

G++ compilation, difference between mac os and ubuntu

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

C++ - gcc o n Fedora Linux

I'm trying to run a simple Hello World! program on a Fedora Linux system through the terminal using gcc, and get the following:
[abder-rahman#Abder Desktop]$ gcc hello.cpp
hello.cpp:1:22: fatal error: iostream.h: No such file or directory compilation terminated.
Why is that? What is going wrong?
Thanks.
You should compile C++ programs with g++, not gcc.
There's no iostream.h header in standard C++. It's iostream (though iostream.h may be offered for backwards compatibility with ancient C++ code).
use g++ instead of gcc
g++ hello.cpp