I have a weird problem on Ubuntu Linux 18.04 that appeared after having run pytest a couple of times. The project is mostly c++, but it also generates pybind11 bindings and generates library files via CMake.
My goal is to force a program to output its files into a specific directory within the project folder, i.e. not in the same directory where the executable file is. I used to achieve that by running this command:
user#computer_name:~/Dev/project$ (cd /home/user/Dev/project/unittests/test_output && "/home/user/Dev/project/./executable" -pdbin /home/user/Dev/project/unittests/test_data/3v8x.pdb -mtzin /home/user/Dev/project/unittests/test_data/3v8x_phases.mtz && cd /home/user/Dev/project)
This command used to work as intended, until today, when I ran some instances of pytest. While pytest is able to complete all tests successfully, my aforementioned command does not work anymore and gives me this error:
user#computer_name:~/Dev/project$ /home/user/Dev/project/./executable: symbol lookup error: /home/user/Dev/project/./executable: undefined symbol: _ZN7library7Class11functionEv
However, when I try to execute the executable in the build directory, like this:
user#computer_name:~/Dev/project$ ./executable
There is no error whatsoever and if I try to give the program its input, the program works as intended without any errors. However, it outputs the files in the build directory - the place where I don't want the output to go.
For further confirmation, I tried to execute the program from another directory again without giving it any input:
user#computer_name:~/Dev/project/unittests$ .././executable
to be greeted yet again with this error:
.././project: symbol lookup error: .././project: undefined symbol: _ZN7library7class11functionEv
So far I've tried to rebuild entire project, generate new Makefiles etc.
I also confirmed that there are no issues with the program itself. Any ideas on how to fix this issue or alternative ways to direct output to different folder without having to pass specific output arguments to the program itself?
If you want executable to pick up the libexecutable.so next to it, you have two options:
Configure LD_LIBRARY_PATH to contain /home/user/Dev/project.
This will make the dynamic linker search there before any other configured directories.
Either do this globally or in a wrapper script.
Compile executable with an rpath. This will make library lookups by executable look in the rpath first. If you pass the -Wl,-rpath,'$ORIGIN'/.. flag (note the single quotes around $ORIGIN!), the dynamic linker will always find libexecutable.so next to executable first.
I'be been trying to install the TSP solver of Concorde on Cygwin, but I'm facing some difficulties :
I downloaded Qsopt on the official website, the two files in the "Cygwin" part, and put them in /home/qs. Then, I download concorde, gunzip it, tar it, so I have /home/concorde. I go in this folder and type "./configure --with-qsopt=/home/qs". Everything seems to go well, so I type "make", and this is what I've got (several lines like this) :
/home/concorde/LP/lpqsopt.c:645 : undefined reference « QSget_param »
/home/concorde/LP/lpqsopt.c:674 : undefined reference « QSset_param »
/home/concorde/LP/lpqsopt.c:650 : undefined reference « QSset_param »
/home/concorde/LP/lpqsopt.c:655 : undefined reference « QSopt_dual »
Do you have an idea on how to solve this ? I didn't find anything on the web.
(I 've got automake 1.15)
The command that produce this error seems to be :
gcc -fPIC -O2 -g -o concorde concorde.o tsp.a ../PQ/pq.a ../VERIFY/verify.a ../LOCALCUT/localcut.a ../TINY/tiny.a ../LINKERN/linkern.a ../EDGEGEN/edgegen.a ../KDTREE/kdtree.a ../FMATCH/fmatch.a ../UTIL/util.a ../BIGGUY/bigguy.a ../CUT/cut.a ../HELDKARP/heldkarp.a ../LP/lp.a ../COMBS/combs.a /home/qs/qsopt.a -liberty -lm ../LP/lp.a(lpqsopt.o)
And then as you see, the errors seems to come from LP
Thanks a lot,
Djazouli
So I found the source code and it looks like the problem is in TSP/Makefile.in.
The problem is that the parameters given to the link editor (ld) are positional: object files (and convenience static archives) need to come before the libraries they link to.
In this case there is a second instance of ../LP/lp.a(lpqsopt.o) being passed at the end, and given nothing to link against. I'm not sure where that is coming from though. The build system is quite a mouthful to figure out where the error comes from.
I am not really sure what's going on here. I'm trying to compile https://github.com/LRN/libntlink so I can easily port this Unix call-reliant code (that project provides windows implementations of symlink() lstat() and macros like S_ISDIR.
Anyway, when I run the supplied cmd file (after changing the variables to point to the right path), I get this:
gcc c:\MinGW\lib\gcc\mingw32\4.9.3\include;c:\MinGW\include -I. -O3 -fno-common
-Wall -mms-bitfields -D_WIN32_WINNT=0x600 -o juncpoint.o -c juncpoint.c
gcc.exe: error: c:MinGWlibgccmingw324.9.3include: No such file or directory
It seems like for some reason all \ are being totally removed from path sometime before gcc.exe parses it to find its stuff. The same thing is happening with c:\MinGW\include. I looked through the makefile, and although I have trouble reading it, I didn't see anything that seemed like it would cause this. This isn't my first time using MinGW, and although the first time failed too, it was for a different reason.
The problem was that the person who wrote the cmd put it in \ path form when it needed to be in / path form for the shell I was in. A different problem shows up now related to permission denied
I'm trying to get up and running with Boost, so I'm trying to compile the simple example problem from Boost's "Getting Started" page. I've had two issues, and I'm not sure they're related (I'm better than a novice, but not by much) but maybe they're related...
1st issue: the "tar --bzip2 -xf /path/to/boost_1_49_0.tar.bz2" command didn't work (yes, I put the correct path in, but it gave me some errors, I forget what they were) so I used "tar -xjvf " from the directory where boost_1_49_0.tar.bz2 was located. That de-compressed the zip file and I proceeded with the example...
2nd issue: The example.cpp file will not compile, the first statement in the code is #include "boost/lambda/lambda.hpp" but then for every header file lambda.hpp is trying access, there's a "No such file or directory" compile error. For example, here are two (of the six, and I get errors for all 6) header files within lambda.hpp and the errors displayed by the cygwin compiler:
boost/lambda/lambda.hpp:14:33: boost/lambda/core.hpp: No such file or directory
boost/lambda/lambda.hpp:21:52: boost/lambda/detail/operator_actions.hpp: No such file or directory
If it helps, this is the command I'm running to compile (I generally create the executable in a separate -o command):
g++ -c example.cpp
Why can't the system find these? I added the installed directory (path/to/boost_1_49_0) to the PATH variable before I started so I know that's no it. Thanks for any advice...
(I've looked on stackoverflow and there were similar issues, but no solutions that worked)
It looks like you've already solved the first issue: namely, that you must specify the -j flag on tar to untar a bzip2'd file.
For the second issue, you need to specify boost on your include path, either by specifying it with the -I command line option or via the CPLUS_INCLUDE_PATH environment variable.
I am trying to execute my first "Hello World!" in C++. I am using Windows XP, and I have installed cygwin, in which the g++ C++ compiler is installed. I have written a small hello-world program, and saved it in hello.cpp. From the command prompt I write:
g++ hello.cpp
But I get:
'g++' is not recognized as an internal or external command, operable program or batch file.
I have installed cygwin in my D:\programs\cygwin. I have made another directory with my hello-world file in D:\cpp. Something with my installation or my paths seems to be not Ok, but I cannot figure what. I have run the exe file of cygwin, and in the installation directory I have got all necessary files, I think: bin folder, lib, Cygwin.bat, etc.
I have read that in case of such error message I should check whether the cygwin1.dll file is copied into the main folder of Windows. Is this the C:\WINDOWS directory? I have looked there, and I don't have such a file there. I have cygwin1.dll in the bin folder of cygwin: D:\programs\cygwin\bin.
Also, how do I check whether the bin folder (D:\programs\cygwin\bin) is considered in the search path of commands?
I think that the hello-world program shouldn't contain any syntax errors, I have just copied it. Also, when I write
g++ -v
I get the same error message: that the command is not recognized.
I would appreciate if someone give me a hint what should I look at. Thank you.
Here is the code of the hello-world program:
#include <iostream>
using namespace std;
int main() {
cout <<"Hello World!"<<endl;
return 0;
}
I have installed g++, and now when I type g++ -v, I get: Reading specs from: \d\cygnus\cygwin-b20\H-i586-cygwin32\bin..\lib\gcc-lib\i586-cygwin32\egcs-2.91.57\specs gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
In the bin directory I have both g++.exe, and gcc.exe. I don't understand why I get "gcc" above and not "g++". I don't know how important this is, but I receive an error message when I try to compile the program in the DOS command prompt:
g++ hello.cpp
I get:
hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
And here is what I get when I try to compile the program in the cygwin shell:
hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
Ah, I have thought that g++ is installed when I install cygwin. So, I should actually first install g++ in that case, shouldn't I?
(and then reboot)
As people have said, check the path. Don't start copying the cygwin DLLs around - that is not necessary, may cauxse problems later and won't solve the problem.
And when it comes to setting the Windows PATH variable (and others) I've found this small program to be quite useful and better than squinting at the MS control panel aplet.
Edit: It seems the OP had mistakenly not installed g++ - a lesson for all of us who replied in asking the obvious question first :-)
I am assuming you are using the Windows Shell here. If you invoke the compiler from a cygwin Bash shell, all the paths should be set for you.
make sure it's on the path or you're running the bash shell cmd prompt.
I wrote a tutorial about this a few years ago, which might help:
http://www.codeguru.com/cpp/misc/misc/compilerandpre-compiler/print.php/c8107__1/
Did you install g++? It's not installed by the default settings of the Cygwin installer.
Are you sure you installed g++? G++ is C++ compiler, not C compiler. If you only installed C compiler, you would have command gcc but not command g++
Make sure they c:\cygwin\bin is in the PATH.
Hope it helps.
To get the path in cygwin:
echo $PATH
This will get us on the road to understanding the problem.
Edit:
The next command will tell us where cygwin thinks it should be looking for all those files within windows
mount
The line which includes /usr/bin is the one we need a copy of.
bring up dos shell.
cd c:\cygwin\bin
type c++ or cpp
or do a directory command do see the contents. Look for cpp or c++.
If they aren't there, you haven't downloaded it.
In addition to adding it to the path (which will fix your problem), you may want to download make and dbg, which are also on the development path but not checked by default. Make sure to select "keep" as the overall install options so it doesn't re-download everything.
As others have mentioned, it's probably a path issue, so you need to look at the environment variable PATH. To do this, right click on My Computer and click "Properties". Go to the "Advanced" tab and click the "Evironment Variables" button. From here, see if the paths you mentioned are included in the PATH variable. If not, add them using the same syntax you see there to separate paths (I think it's a semi-colon or a colon between paths.)
Edit: Ah, I see you've already done this (beat my post by mere seconds.) I think all you need to do now is reboot.
Try to create a new file and type in the code yourself without copying and pasting it.
You may have an illegal character in your code which may not be visible in your editor of choice.