When try to the 2nd example https://octave.org/doc/v5.1.0/Standalone-Programs.html#Standalone-Programs I got the following error :
embedded.cc:(.text+0x132): undefined reference to `octave::feval(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, octave_value_list const&, int)'
The -d option of the mkoctfile provides the following two g++ commands, where the 1st one works fine.
g++ -std=gnu++11 -c -fPIC -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave/.. -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include -pthread -fopenmp -fPIC embedded.cc -o /tmp/oct-EYDDih.o
and
g++ -std=gnu++11 -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave/.. -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include/octave-5.1.0/octave -I/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/include -pthread -fopenmp -fPIC -rdynamic -fPIC -o embedded /tmp/oct-EYDDih.o -L/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/lib -L/grid/common/pkgsData/octave-v5.1.0/Linux/RHEL7.0-2017-x86_64/lib/octave/5.1.0 -loctinterp -loctave
Any idea how to solve this ?
I found in the the root cause for this issue, there was an EDA tool (Cadence Xcelium) module loaded which let g++ point to its private version, when I replace g++ with /bin/g++ it works in my environment.
Related
I am trying to use std::sort(std::execution::par,x.begin(),x.end()) ; so I need to tell the compiler that c++17 or c+20 should be used.
In my make file I wrote:
CXX_COMPILE=mpic++ -std=c++17 -fopenmp -Wall -Wextra -fPIC $(OPT_DEBUG) CXX_LINK=mpic++ -fPIC $(EXTRAFLAGS) $(OPT_DEBUG)
I got the error that:
fatal error: tbb/blocked_range.h: No such file or directory
so I installed tbb and modified CXX_COMPILE to be:
CXX_COMPILE=mpic++ -ltbb -std=c++17 -fopenmp -Wall -Wextra -fPIC $(OPT_DEBUG)
Compiling this gave me bunch of errors telling:
undefined reference to `typeinfo for tbb::task'
internal::allocate_continuation_proxy::allocate(unsigned long) const'
tbb::internal::allocate_child_proxy::allocate(unsigned long) const'
Is anything wrong in Makefile?
This may be a bit of a weird request but I'm trying to compile some software with g++ with the -nostdlib flag.
I'm pretty new to c++ and I'm still learning how linking and compiling works but I'm trying to compile this code:
#include "../lib/gamesys/types.h"
int main() {
types::setUid(1001);
}
Using these commands:
g++ -Wall -g -c bin/scripttwo.cpp -o bin/scripttwo.o -std=c++14
and
g++ -o bin/scripttwo bin/scripttwo.o software/*.o hardware/*.o *.o -nostdlib -Llib/lib/ -ltypes -ljsoncpp -lreadline -ltypes
and I'm getting the error:
/usr/bin/ld: software/FS.o: undefined reference to symbol '_Unwind_Resume##GCC_3.0'
/usr/bin/ld: /lib64/libgcc_s.so.1: error adding symbols: DSO missing from command line
I'm assuming it has something to do with the stdlib because once I remove -nostdlib, it compiles and links fine.
How can I solve this (it is pretty important that I don't include stdlibs)
Note: If you want to know why I'm trying to avoid stdlibs, let me know, its a long a convoluted story lol
Getting this error when compiling and linking the minimal.cpp file from the samples directory
g++ -o "SampleMinimal" ./src/minimal.o -lwx_mswu_xrc-3.0-x86_64-w64-mingw32 -lwx_mswu_webview-3.0-x86_64-w64-mingw32 -lwx_mswu_html-3.0-x86_64-w64-mingw32 -lwx_mswu_qa-3.0-x86_64-w64-mingw32 -lwx_mswu_adv-3.0-x86_64-w64-mingw32 -lwx_mswu_core-3.0-x86_64-w64-mingw32 -lwx_baseu_xml-3.0-x86_64-w64-mingw32 -lwx_baseu_net-3.0-x86_64-w64-mingw32 -lwx_baseu-3.0-x86_64-w64-mingw32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -Wl,--subsystem,windows -mwindows -Wl,--enable-auto-import
/usr/lib/gcc/x86_64-pc-cygwin/9.3.0/../../../../x86_64-pc-cygwin/bin/ld: ./src/minimal.o: in function `wxString::ImplStr(char const*, wxMBConv const&)':
/usr/x86_64-w64-mingw32/sys-root/mingw/include/wx-3.0/wx/string.h:477: undefined reference to `wxString::ConvertStr(char const*, unsigned long, wxMBConv const&)'
/usr/x86_64-w64-mingw32/sys-root/mingw/include/wx-3.0/wx/string.h:477:(.text$_ZN8wxString7ImplStrEPKcRK8wxMBConv[_ZN8wxString7ImplStrEPKcRK8wxMBConv]+0x3a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `wxString::ConvertStr(char const*, unsigned long, wxMBConv const&)'
collect2: error: ld returned 1 exit status
Successfully creating object file.
Compiler command line:
g++ -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXMSW__ -I/usr/x86_64-w64-mingw32/sys-root/mingw/lib/wx/include/x86_64-w64-mingw32-msw-unicode-3.0 -I"/usr/x86_64-w64-mingw32/sys-root/mingw/include/wx-3.0" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/minimal.d" -MT"src/minimal.o" -o "src/minimal.o" "../src/minimal.cpp"
Finished building: ../src/minimal.cpp
Linker command line:
g++ -o "SampleMinimal" ./src/minimal.o -lwx_mswu_xrc-3.0-x86_64-w64-mingw32 -lwx_mswu_webview-3.0-x86_64-w64-mingw32 -lwx_mswu_html-3.0-x86_64-w64-mingw32 -lwx_mswu_qa-3.0-x86_64-w64-mingw32 -lwx_mswu_adv-3.0-x86_64-w64-mingw32 -lwx_mswu_core-3.0-x86_64-w64-mingw32 -lwx_baseu_xml-3.0-x86_64-w64-mingw32 -lwx_baseu_net-3.0-x86_64-w64-mingw32 -lwx_baseu-3.0-x86_64-w64-mingw32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -Wl,--subsystem,windows -mwindows -Wl,--enable-auto-import
You're apparently compiling minimal sample in debug mode, see -g3 flag, then attempting to link against release mswu libs.
So either change the sample compilation to release mode, or change the linker command to use mswud debug libs.
Solved the problem by making Command: x86_64-w64-mingw32-g++ for both the GCC C++ compiler and the MinGW C++ Linker in the C/C++ build settings in Eclipse. I thought this was done automatically by selecting the MinGW tool chain. Many thanks to Catalin for pointing out that I was linking against release libraries in the debug build configuration. His answer to make my build configuration release got me that one step further. Thanks!
This question already has answers here:
Why does the order in which libraries are linked sometimes cause errors in GCC?
(9 answers)
Closed 5 years ago.
There are linker errors to Symbols defined by SFML, but i cannot see how they occur despite that I linked the lib.
I'm using make, which I currently learn and I want to build a minimalistic dev-environment with it.
Give a holler if you need anymore information than the following. I'd just like to minimize the questions size.
XXX#XXX ~/Documents/dev/cpp/proj/beep $ make clean
rm -f build/*.o build/release/*.o build/debug/*.o build/test/*.o
XXX#XXX ~/Documents/dev/cpp/proj/beep $ make tests
//test obj first
g++ -std=c++14 -Wall -pthread -Iinclude -c test/Packager.ut.cpp -o build/test/Packager.ut.o -g3
//now the src obj
g++ -std=c++14 -Wall -pthread -Iinclude -c src/ClientAddress.cpp -o build/debug/ClientAddress.o -g3
g++ -std=c++14 -Wall -pthread -Iinclude -c src/Packager.cpp -o build/debug/Packager.o -g3
g++ -std=c++14 -Wall -pthread -Iinclude -c src/Package.cpp -o build/debug/Package.o -g3
Built debug object files.
//now the first test itself
g++ -std=c++14 -Wall -pthread -Iinclude -lsfml-network build/test/Packager.ut.o build/debug/ClientAddress.o build/debug/Packager.o build/debug/Package.o -g3 -o bin/test/Packager.ut
build/test/Packager.ut.o: In function `main':
/home/XXX/Documents/dev/cpp/proj/beep/test/Packager.ut.cpp:69: undefined reference to `sf::IpAddress::IpAddress(char const*)'
build/debug/ClientAddress.o: In function `nw::udp::ClientAddress::ClientAddress()':
/home/XXX/Documents/dev/cpp/proj/beep/src/ClientAddress.cpp:21: undefined reference to `sf::IpAddress::IpAddress(char const*)'
build/debug/ClientAddress.o: In function `nw::udp::operator==(nw::udp::ClientAddress const&, nw::udp::ClientAddress const&)':
/home/XXX/Documents/dev/cpp/proj/beep/src/ClientAddress.cpp:33: undefined reference to `sf::operator==(sf::IpAddress const&, sf::IpAddress const&)'
...
and so on ... every mentionings of sf:: inside the files are quoted
I get the same error pattern if I try to compile the other tests (for ClientAddress for example)
Of course i now want to know what i linked wrong how there. As you can see the lib is linked with -lsfml-network. I also checked the SMFL installation, so it is at least less likely a lib file gone missing from standard directory.
I guess there is an error in my usage of g++ , compiling and linking orders or smth.
My project tree:
>bin
----mainexec
--->test
----.ut
>build
--->debug
----.o
--->release
----.o
--->test
----.ut.o
>src
---- .cpp
>include
---- .h
>test
---- .ut.cpp
As a second part of the question, I'd like to ask if there is a better way to build tests, because I simply link every src-obj with my test-obj, even if there are way more src-obj linked than it actually needs. It should work and I do not have to maintain my test dependencies all the time, which later would be very cumbersome. What is common ?
sfml-network has a dependency on sfml-system. Try add -lsfml-system before -lsfml-network in your linker command in your makefile
I got following error while compiling library that computes some stuff with molecules. It is mostly academic project.
/usr/bin/ld: trajectory_manager.o: undefined reference to symbol '_ZSt24__throw_out_of_range_fmtPKcz##GLIBCXX_3.4.20'
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
It occurs to me that linker is trying to use some specific version of GLIBC but fails to find it or something but I am unable to find any solution to this at all.
The code was compiled using g++ (gcc version 5.3). Linker I have in version ldd (Ubuntu EGLIBC 2.19-0ubuntu6.7) 2.19. If necessary please tell me in comment section and I will provide any further information.
Edit:
Each src is compiled using:
mpiCC -pthread -ansi -Wno-long-long -g -D_DEBUG -I /home/asd/tunnel_analyzer/boost_lib/include -I ../../../src/lib -o main.o -c ../../../src/main/main.cpp
mpiCC -pthread -ansi -Wno-long-long -g -D_DEBUG -I /home/asd/tunnel_analyzer/boost_lib/include -o cache.o -c ../../../src/lib/cache.cpp
etc. and linked
mpiCC -pthread -ansi -Wno-long-long -g -D_DEBUG -I /home/asd/tunnel_analyzer/boost_lib/include -L/home/asd/tunnel_analyzer/boost_lib/lib -L. -o caverdock main.o cache.o coords.o current_weights.o everything.o grid.o szv_grid.o manifold.o model.o monte_carlo.o mutate.o my_pid.o naive_non_cache.o non_cache.o parallel_mc.o parse_pdbqt.o pdb.o quasi_newton.o quaternion.o random.o ssd.o terms.o weighted_terms.o constraint.o scheduler.o trajectory_manager.o -l boost_system -l boost_thread -l boost_serialization -l boost_filesystem -l boost_program_options
Note that mpiCC is just alias for g++.
it seems to be a G++ bug; installing libstdc++6 (4.9) apparently helps solve this.