I installed Flex 2.5.4a and gcc compiler on windows. I also 've Dev-Cpp.
To compile the lex program, I used : flex file.l.
Now I got lex.yy.c, which I compiled using gcc compiler : gcc lex.yy.c.
It gave an error showing:
c:/program files (x86)/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../../mingw32/bin/ld.exe: cannot find -lfl
collect2.exe: error: ld returned 1 exit status
though I did include GnuWin32 bin path in path variable in environmental variables.Can someone tell me how to correct this error?
If you provide a main() and use option noyywrap, you don't need -lfl anymore...
%option noyywrap
%%
...your flex
%%
int main(){
yylex();
return 0;
}
Related
I guess I don't have enough experience installing software with g++. I am trying to install FIt-SNE. I am following the installation instructions. I have already installed FFTW, and I just need to execute the following line:
g++ -std=c++11 -O3 src/sptree.cpp src/tsne.cpp src/nbodyfft.cpp -o bin/fast_tsne -pthread -lfftw3 -lm -Wno-address-of-packed-member
And I get this error:
In file included from src/tsne.cpp:40:0:
src/nbodyfft.h:7:10: fatal error: fftw3.h: No such file or directory
#include <fftw3.h>
^~~~~~~~~
compilation terminated.
In file included from src/nbodyfft.cpp:5:0:
src/nbodyfft.h:7:10: fatal error: fftw3.h: No such file or directory
#include <fftw3.h>
^~~~~~~~~
compilation terminated.
I understand that the installer is not finding the FFTW package, and I think I need to provide the path to the installation somehow to the installer, but I don't know how to do it. Can anyone help me with this?
I'm triing to compile the superoptimizer on windows. (https://github.com/bonzini/superopt)
Unfortunatly my knowledge of make is very limited. I tried:
make CPU=-D386 superopt
Which gives me the error:
cc superopt.c -o superopt
process_begin: CreateProcess(NULL, cc superopt.c -o superopt, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [superopt] Fehler 2
After setting the compiler to gcc manually with:
make CPU=-D386 superopt CC=gcc
I get the following error:
gcc superopt.c -o superopt
In file included from superopt.c:27:0:
superopt.h:104:2: error: #error You have to choose target CPU type (--with-arch).
#error You have to choose target CPU type (--with-arch).
^
In file included from superopt.h:130:0,
from superopt.c:27:
longlong.h:1465:14: error: unknown type name 'UQItype'
extern const UQItype __clz_tab[];
^
superopt.c:32:21: fatal error: version.h: No such file or directory
compilation terminated.
make: *** [superopt] Fehler 1
It seems it does't properly selects i386.
Any hints would be greatly appreciated.
That is not the source code of
GNU superopt. It is the source code of someone's project
to patch GNU superopt, last updated 2008, and seemingly
abandoned a hard-hat area.
This is the source code of
GNU superopt. Extract the tarball and build as you have attempted
with:
make CC=gcc CPU=-DI386 superopt
Note: I386, not 386.
You will see warnings like:
warning: incompatible implicit declaration of built-in function 'foo'
because the 20 yearold C code does not diligently include the standard
headers that prototype the standard functions that it calls, but superopt will build successfully.
I built gcc 4.9.0 from source, and was also planning on building clang 3.4.2, however something seems to have gone awry with regards to libstdc++, as the clang build baled pretty quickly with the linker complaining about various undefined references from std.
Indeed, I then tried compiling and linking the trivial program:
#include <iostream>
int main() {
std::cout << 42;
}
and again hit linker errors:
/tmp/ccrptgVW.o:temp.cpp:function main: error: undefined reference to 'std::cout'
/tmp/ccrptgVW.o:temp.cpp:function main: error: undefined reference to 'std::ostream::operator<<(int)'
/tmp/ccrptgVW.o:temp.cpp:function __static_initialization_and_destruction_0(int, int): error: undefined reference to 'std::ios_base::Init::Init()'
/tmp/ccrptgVW.o:temp.cpp:function __static_initialization_and_destruction_0(int, int): error: undefined reference to 'std::ios_base::Init::~Init()'
collect2: error: ld returned 1 exit status
(full gcc -v output), both with my freshly-minted gcc 4.9.0 and my Ubuntu's stock gcc 4.6.3.
libstdc++.so exists, in /usr/local/lib64:
ls /usr/local/lib64/libstd*
/usr/local/lib64/libstdc++.a
/usr/local/lib64/libstdc++.so
/usr/local/lib64/libstdc++.so.6.0.20
/usr/local/lib64/libstdc++.la
/usr/local/lib64/libstdc++.so.6
/usr/local/lib64/libstdc++.so.6.0.20-gdb.py
and this directory appears in LIBRARY_PATH and as an -L argument to collect2 in the verbose gcc output.
How do I restore sanity to my system and have the linker find the shared library?
As turns out from your comment, you compiled with gcc rather than g++.
Do not take it as an error, as the compilation went fine! What's showing up is a linker error. Indeed, gcc will tell ld to link against the C standard library rather than the C++ standard one.
To solve, either go for g++ directly or pass -lstdc++.
I want to compile opentracker(https://erdgeist.org/arts/software/opentracker) on my machine osx 10.9. when run "make" command I get this error:
cc -c -o opentracker.o -I../libowfat -Wall -pipe -Wextra -O3 -DWANT_FULLSCRAPE
opentracker.c
opentracker.c:25:10: fatal error: 'io.h' file not found
#include "io.h"
^
1 error generated.
make: *** [opentracker.o] Error 1
what is the problem? Is there any way to install io.h through homebrew?
You may have sorted this out already but i'll put this here for anyone else who has the same problem.
The "-I../libowfat" tells the compiler to include that path in the search path for header files. io.h is part of libowfat which you need to compile opentracker.
You can get libowfat here http://www.fefe.de/libowfat/
Unpack it and place it one directory up from where you are compiling opentracker. Alternatively you can change the -I to point to where you have libowfat unpacked.
I can't get an external library link with the main program using premake. For instance I've simplified the problem to this example:
./_external/ext.cpp
#include "ext.h"
int foo()
{
return 4;
}
./_external/ext.h
#pragma once
int foo();
./main.cpp
#include "stdio.h"
#include "_external/ext.h"
int main()
{
printf("%d", foo());
return 0;
}
./premake4.lua
solution "Test"
configurations { "Release", "Debug" }
project "TestMain"
language "C++"
kind "ConsoleApp"
files "main.cpp"
links
{
"_external/libfoo.a"
}
I create the GNU makefiles under Cygwin environment:
$ ./premake4.exe gmake
Building configurations...
Running action 'gmake'...
Generating Makefile...
Generating TestMain.make...
Done.
and I get the following error when I make:
$ make
==== Building TestMain (release) ====
Linking TestMain
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lD:/test/_external/libfoo.a
collect2: ld returned 1 exit status
TestMain.make:93: recipe for target `TestMain.exe' failed
make[1]: *** [TestMain.exe] Error 1
Makefile:16: recipe for target `TestMain' failed
make: *** [TestMain] Error 2
The only workaround I found is to use "linkoptions" instead of "links" to get rid of the "-l" but for me it's more like a hack than a solution.
You are doing it right, but Premake is getting it wrong. There was a bug in Premake's makefile generator that prevented things from linking properly. It is now fixed in both the stable (will become version 4.4) and dev (will become 5.0) repositories.
Nice to get that fixed—hope it helps.