unistd : no such file or directory [closed] - c++

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have the following test.cpp file :
#include <unistd>
int main()
{
return 0;
}
I just want to compile this but I still have the following :
$ g++ test.cpp
test.cpp:1:18: fatal error: unistd: No such file or directory
#include <unistd>
^
compilation terminated.
I found unistd.h at /usr/include/unistd.h. and my $LD_LIBRARY_PATH environment variable was empty so I set it at /usr/include (with export LD_LIBRARY_PATH=/usr/include) but the problem remains.
What could I do?

The name of the header is unistd.h, not unistd. And LD_LIBRARY_PATH is used to locate shared libraries, not header files.

Related

view_string MSYS2 MinGW x64 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 days ago.
Improve this question
Compiling with
g++ detect_version.cpp -o detect_version.exe
and running the following program:
int main()
{
std::cout << "Version is: " << __cplusplus;
return 0;
}
Gives me: "Version is: 201703" which is C++17 that should contain <view_string>
However if write
#include <view_string>
It gives me:
detect_version.cpp:3:10: fatal error: view_string: No such file or directory
3 | #include <view_string>
| ^~~~~~~~~~~~~
compilation terminated.
Under MSYS2 MinGW libstdc++ should be mingw-w64-x86_64-gcc-libs and from that I do have the latest version:
$ pacman -Q | grep mingw-w64-x86_64-gcc-libs
mingw-w64-x86_64-gcc-libs 12.2.0-10
What could be the problem?

Pcap functions undefined reference [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm trying to add pcap functions into my C++ project in Clion on linux.
My h file contains:
#include <pcap/pcap.h>
And the CMAKE file was updated as well.
Instead of using the next command:
if (NOT MSVC)
target_link_libraries(${TARGET} pthread)
endif()
it is now:
if (NOT MSVC)
target_link_libraries(${TARGET} pthread pcap)
endif()
still getting the next errors:
undefined reference to "pcap_open_dead"
undefined reference to "pcap_dump_open"
undefined reference to "pcap_dump_close"
undefined reference to "pcap_close"
Anyone knows how to solve it?
Thanks
Thanks for the help!
After using the VERBOSE flag I was able to see the problem.
I added the pcap flag in another CMAKE file and now it works :)

a.exe: file not recognized: File truncated [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
It was working perfectly for others c file but in this file it fail to run . Please do explain , as i am new to Programming world.
C:\Desktop\C Basic\recursiveFunction> gcc .\pratice.c
PS C:\Desktop\C Basic\recursiveFunction> gcc .\a.exe
.\a.exe: file not recognized: File truncated
collect2.exe: error: ld returned 1 exit status
gcc is the compiler. You compile your program using gcc .\pratice.c. You can remove the .\ since gcc will look in the current directory for source files anyway.
You execute your compiled program using .\a.exe.

cout not printing to terminal screen C++ [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I'm running a .cpp file and trying to print out to the screen for debugging purposes, however my message does not appear. I'm running my program from the Linux Terminal using the following command:
g++ -m32 -static genConfig.cpp -o genConfig
All that my .cpp file should do at this point is cout to the terminal as show below. However the output doesn't appear.
#include <string>
using namespace std;
int main(int argc, char ** argv) {
cout<<"HEYYYA";
}
The command g++ -m32 -static genConfig.cpp -o genConfig does not run the application, it compiles (and links) it. In order to run the generated binary, you need to execute ./genConfig.
Also, you need #include <iostream> and actually #include <string> is not needed (at least not for this specific portion of code).

How Can i Compile My C++ Project? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
it keeps telling me
gcc hello.cpp -o hello
gcc: error: hello.cpp: No such file or directory
gcc: fatal error: no input files
compilation terminated.
please anyone help
The source file needs to be in the same path you invoke gcc or you can put the full path in there
gcc /home/username/Desktop/hello.cpp
or you can do cd /home/username/Desktop then invoke gcc from that given path.
set your current directory where the .cpp file is