I am running Kali-Linux (debian+gnome). When I compile I get compilation error:
cc -Wall -g -c -o frag.o frag.c
frag.c:7:10: fatal error: stropts.h: No such file or directory
7 | #include <stropts.h>
| ^~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: frag.o] Error 1
Can anyone tell me what am I missing and what should I install?
I tried installing glibc-sources but still it didn't work out.
As mentioned by the other answer, this library is not used on Linux. Since this came up when trying to compile an application on Linux, it's possible an #if was not set correctly.
As a workaround, look at the source code to see what the #if surrounding the #include is, and set that to false when compiling.
For example, if the code looked like:
#if HAVE_STROPTS_H
#include <stropts.h>
#endif
And if you are using cmake or gcc, run them with -DHAVE_STROPTS_H=0.
stropts.h is part of the Posix STREAMS extension, which Linux never supported. (Since 2008, it has also been marked as obsolescent by Posix, so it may be removed in some future standard revision.)
There have been third-party implementations of STREAMS for Linux, but I don't kniw if any of them are still supported. One which is used by Linux-based telephony apps is contained in openss7.
Another reason not yet mentioned might be the confusion manual introduces. If you need to use ioctl() call, the quickest way to find out the header to include might be pulling up a man ioctl. Well, it turns out there are 2 different manual pages for ioctl(), and having both on the system will result in this misleading and wrong suggestion (accessible directly as man 3 ioctl) of including the stropts.h.
More likely you actually need a sys/ioctl.h, described in man 2 ioctl:
#include <sys/ioctl.h>
Related
I just started using MinGW for Windows. When trying to create executable using
g++ a.cpp -o a.exe -std=c++14
for the code below:
#include <string>
using namespace std;
int main()
{
string x = to_string(123);
return 0;
}
I'm getting following error:
C:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of vsnprintf
C:\Users\..\Local\Temp\cc4sJDvK.o:c:/mingw/include/stdio.h:426: first defined here
collect2.exe: error: ld returned 1 exit status
What is the root cause for this error and how can I make it go away? While I can easily find a replacement for to_string() function I'm not sure what is causing this error to occur in the first place.
Installing MinGW packages mingw32-libmingwex-* will link an appropriate version of vsnprintf and avoid the linker error.
This issue, i.e. multiple definition of vsnprintf, still exists in MinGW as December 2019.
After investigating a lot, I found the solution in the official mailing list.
It's a bug in mingwrt-5.2.2. Downgrading to the mingwrt-5.2.1 version solves that issue.
To do that, just input the following command:
mingw-get upgrade mingwrt=5.2.1
Then restart the MinGW shell.
Read the full story here.
Note: MinGW-w64 and MinGW are separate projects, so the accepted solution is not so helpful to me, as I want to keep MinGW and not to move to MinGW-w64.
I solved this issue using MinGW w64 compiler
download mingw-w64-install.exe
setup to Version: 6.3.0, Architecture: i686, Threads: posix, Exception: dwarf and Build revision: 2.
I hope this will be of some help.
There are multiple definitions of vsnprintf in both stdio.h and libmingwex.a. I am able to work this around by adding #define __USE_MINGW_ANSI_STDIO 0 to the start of the code, before any includes, which disables the definition of vsnprintf in stdio.h.
I am having a hard time figuring out how to add getopt.h in my AIX 7.1. I am using the getopt_long function in my code, which I know is in getopt.h instead of unistd.h (which contains getopt()).
This code is not compiling in AIX:
fatal error: getopt.h: No such file or directory
#include <getopt.h>
^
compilation terminated.
Here are the gcc packages installed:
gcc-4.8.3-1.aix7.1.ppc.rpm
gcc-c++-4.8.3-1.aix7.1.ppc.rpm
libgcc-4.8.3-1.aix7.1.ppc.rpm
gcc-cpp-4.8.3-1.aix7.1.ppc.rpm
I have gone through these links, but they haven't helped much:
http://www.ibm.com/developerworks/aix/library/au-unix-getopt.html#sthash.Loz3H0AH.dpuf
http://www.linuxmisc.com/8-freebsd/eb9bdab1cf6044d5.htm
Also a lot of other web searches.
Am I missing some rpms, or some environment variables?
getopt_long is GNU-only, but you can take free implementation (for example, this claims that it is of BSD license, if I understand it right) or write your own implementation (it's not so hard) and use it in your code.
I am trying to compile a library using clang. The library makes calls to 'unlink', which is not defined by clang:
libmv/src/third_party/OpenExif/src/ExifImageFileWrite.cpp:162:17: error: use of undeclared identifier 'unlink'; did you mean 'inline'?
unlink( mTmpImageFile.c_str() ) ;
My question is, what is the clang equivalent of unlink? As I see it, the path forward would be to #define unlink somewhere with an equivalent routine.
There is no "Clang equivalent". Neither GCC nor Clang have ever been responsible for defining unlink, though they do probably distribute the POSIX headers which do (I don't recall specifically where POSIX headers come from).
Unfortunately, this appears to be a bug with the library you're using; the OpenExif developers failed to include the correct headers. Different C++ implementations may internally #include various headers for their own purposes, which has apparently masked this bug on your previous toolchain.
You can hack your copy and/or submit a patch to add:
#include <unistd.h>
I am running 64bit Linux and using Netbeans 8.0 IDE. I simply created new C++ project, so far only containing some HelloWorld code. I want to use a third party library for logging. I chose log4cpp (since I have experience with Java and it is supposed to have similar interface).
I installed liblog4cpp from the repositories, and can see it in /usr/lib, to be clear:
$ locate log4cpp
/usr/lib/liblog4cpp.so
/usr/lib/liblog4cpp.so.5
/usr/lib/liblog4cpp.so.5.0.5
/usr/lib/x86_64-linux-gnu/liblog4cpp.so
/usr/lib/x86_64-linux-gnu/liblog4cpp.so.5
/usr/share/doc/liblog4cpp5
/usr/share/doc/liblog4cpp5/AUTHORS
/usr/share/doc/liblog4cpp5/NEWS.gz
/usr/share/doc/liblog4cpp5/README
/usr/share/doc/liblog4cpp5/THANKS
/usr/share/doc/liblog4cpp5/TODO
/usr/share/doc/liblog4cpp5/changelog.Debian.gz
/usr/share/doc/liblog4cpp5/changelog.gz
/usr/share/doc/liblog4cpp5/copyright
/var/cache/apt/archives/liblog4cpp5_1.0-4_amd64.deb
/var/lib/dpkg/info/liblog4cpp5.list
/var/lib/dpkg/info/liblog4cpp5.md5sums
/var/lib/dpkg/info/liblog4cpp5.postinst
/var/lib/dpkg/info/liblog4cpp5.postrm
/var/lib/dpkg/info/liblog4cpp5.shlibs
I am having big trouble on how to #include it in my application. Inspired by example from the documentation I put in my source:
#include "log4cpp/Category.hh"
#include "log4cpp/Appender.hh"
#include "log4cpp/FileAppender.hh"
#include "log4cpp/OstreamAppender.hh"
#include "log4cpp/Layout.hh"
#include "log4cpp/BasicLayout.hh"
#include "log4cpp/Priority.hh"
I was first using Makefile generated by netbeans, however could not figure out how to configure the project to make it work. All my trials lead to the following error (line 16 being the first #include):
$ make
src/main.cpp:16:31: fatal error: log4cpp/Category.hh: No such file or directory
compilation terminated.
make: *** [build/NetworkConfiguration.o] Error 1
I also tried a custom Makefile, giving g++ argument -llog4cpp, but I always get the same error. I can provide more info/code if it will be helpful. The solution does not need to depend on the IDE, I feel like I just misunderstood how linking works, so feel free to educate me on how to achieve what I want from console with custom Makefile for example.
Since cup still has not posted an answer, I am paraphrasing his comment as an accepted answer.
Install liblog4cpp-dev. The difference is that liblog4cpp only contains the libraries while liblog4cpp-dev is the development kit which includes the headers.
I was using flex and bison to build a simple calculator project I cloned from Github.
But after I typed make in terminal, I got the following message:
gcc -o calc calc.tab.c lex.yy.c -lfl
calc.y:48:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main() {
^~~~
1 warning generated.
ld: library not found for -lfl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [calc] Error 1
How could I resolve this problem?
let me guess, trying to use flex on OS/X?
Try -ll instead of -lfl
Using Flex on OS/X
So yea, the flex library name on OS/X is just arbitrarily different for some reason. OS/X is not exactly Linux, but it's pretty close. You have some options here.
You can just simply have a separate build system and source files for OS/X. Certainly Apple might like that with their pushing XCode, objective-C and not much interoperability.
You can build vs Linux and then engage with Mac Ports and Homebrew.
You can create your project using autotools. That's not an awesome link, learning this system is rough going, but it's a standard thing for Linux for sure. This will actually work, I find if you have the patience for it, OS/X is close enough that autotools based builds will work on it.
Lately, I've been turned on to Cocoapods, which I believe to be an attempt to join the open source community and XCode. It's kind of half 1 and 3 sorta with an emphasis on modularizing the external source and getting it compiled into a .app (via Xcode).
warning: type specifier missing, defaults to 'int'
mean that you should declare return type for main function. Place int in function difinition.
ld: library not found for -lfl
flag -l mean that compiller must use libfl.a to build programm. As #waTeim said above, for Mac OS you can use libl.a instead, but this lib can be not exist alse. There is another way is to place
%option noyywrap
at the top of flex *.l file. In this case you can compile without additional libs.