Armadillo Wrapper Linker errors - armadillo

When using some functions in the Armadillo Algebra package I get the following errors:
armadillo_bits/atlas_wrapper.hpp:188: undefined reference to `clapack_dgetrf'
I have linked like this:
arm-linux-gnueabihf-g++ -march=armv7-a -mthumb-interwork -mfloat-abi=hard
-mfpu=neon
-mtune=cortex-a9 --sysroot=/home/mg/yocto/build/tmp/sysroots/socfpga_cyclone5
-DHAVE_CONFIG_H -I. -I.. --sysroot=/home/mg/yocto/build/tmp/sysroots
/socfpga_cyclone5 -g -O2 -L/opt/altera-linux/linaro/gcc-linaro-arm-linux-gnueabihf-
4.7-2012.11-20121123_linux/arm-linux-gnueabihf/lib -I/opt/altera-linux/linaro
/gcc-linaro-arm-linux-gnueabihf-4.7-2012.11-20121123_linux/arm-linux-gnueabihf
/include -llapack -lf2c -lblas -lm --sysroot=/home/mg/yocto/build/tmp/sysroots
/socfpga_cyclone5 -MT AlgoLibTests.o -MD -MP -MF .deps/AlgoLibTests.Tpo -c -o
AlgoLibTests.o AlgoLibTests.cpp
I followed the instructions here and everything went fine:
Cross-Compiling Armadillo Linear Algebra Library
Any Ideas?

It also took me some days to be able to install armadillo for my Android development. So I want to shared with you the experience to solve your problem.
The error undefined reference to `clapack_dgetrf' is a linking error. This function should be contained in one of these libraries -llapack -lf2c -lblas. Of course it is clapack, so it should be in the lapack library. Use the command nm to check if the lapack library (liblapack.a or liblapack.so) contains this symbol. I am sure you will find out the solution then. Hope it helps.

Related

Why -pthread working but -lpthread does not?

I have successfully linked my simple gtest test with command
g++ -o build/test1 build/test1.o -pthread -lgtest -lgtest_main
but i'm curios about options -pthread. Why it is not working with -lpthread as
it working with -lgtest.
And why -gtest doest not working but -pthread without "l" is working...
I have successfully linked my simple gtest test with command g++ -o
build/test1 build/test1.o -pthread -lgtest -lgtest_main
but i'm curios about options -pthread. Why it is not working with
-lpthread as it working with -lgtest.
The order of library link options on the command line is significant. I take it that you tried simply changing -pthread to -lpthread in place, to get this:
g++ -o build/test1 build/test1.o -lpthread -lgtest -lgtest_main
But if the gtest or gtest_main library uses any pthreads functions, then -lpthread needs to appear later in the library list than those (libraries can be listed more than once if necessary):
g++ -o build/test1 build/test1.o -lgtest -lgtest_main -lpthread
Although that's not the appropriate way to build pthreads code with g++ (as described in your other answer), it typically does work.
And why -gtest doest not working but -pthread without "l" is
working...
-pthread is a specific compilation option recognized by the GCC suite of compilers. -lgtest is a combination of the general -l option with gtest as an option argument. One can also write the analogous -lpthread option, which, in principle, has a somewhat different meaning than -pthread.
In gcc, the -pthread flag is an indication to the compiler that it should set up things to allow for threaded code. I believe (but I'm not absolutely sure) that one of the things it does is add -lpthread so that the linker will use the relevant libraries when searching for unresolved symbols.
However, it also does other things, like set -D_REENTRANT to specify the use of re-entrant code.
In other words, -lpthread may not be enough on its own, since it only specifies that the threading library should be searched. I tend to use both to be certain that it does the right thing - yes, I am paranoid :-)

How to compile C into a universal library that works with iOS architectures

I'm trying to compile a very small amount of C source into a library that I can use in XCode for an iOS application.
The files are a single .c file and three header files. I'm very new to C, and no matter what I try I can't seem to get them to compile into a library that supports iOS architectures.
The files depend on the openssl library, and I've got that installed and working fine.
I just need to know the process of compiling these four files into a single library. I've found a plethora of information on the subject online, but I can't decipher which parts are necessary for what I'm trying to do.
I've tried the following:
gcc -fPIC -c main.c
gcc -shared -o mylib.so main.o -lcrypto -lssl
which seems to compile it for x86_64, (I've not tested the resulting file, just checked it's arch).
I've also tried
./configure --disable-shared --enable-utf8 --host=arm-apple-darwin CFLAGS="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk" CXXFLAGS="-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk" LDFLAGS="-L." CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc" CXX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++"
which only gives me errors
checking for arm-apple-darwin-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/nathanf/compilec':
configure: error: C compiler cannot create executables
I've been scouring the internet for the last few days trying to figure this out, but it's so convoluted to cross compile just a few files and I'm frustrated so I came here for some input.
Any help would be greatly appreciated.

Can't Compile Crypto++ Library for IOS

I'm trying to build a static cryptopp library for ios. I'm basing my steps from these sites:
http://cryptopp.com/wiki/IOS_(Command_Line)#Xcode_Project
https://github.com/noloader/cryptopp-5.6.2-ios
https://www.cryptopp.com/
1.) I downloaded the latest cryptopp version 5.6.3
2.) I downloaded noloader's cryptopp-5.6.2-ios becasue it has updated:
setenv-ios.sh - i had to edit this to search for sdk 9.2
GNUmakefile
config.h
build-for-ios.sh
3.) I copied the four files to my cryptopp 5.6.3 directory and replaced GNUmakefile and config.h
4.) I checked out IOS_Command_Line instruction to invoke setenv-ios.sh first.
5.) Then, as noloader said, run build-for-ios.sh.
However, i'm getting this error:
Has anyone successfully built the library using the latest ios SDK and cryptopp version? If so, can you please point me to the right direction. Thanks.
The documentation was not correct under IOS (Command Line) | Build the Library. After setting the environment with setenv-ios.sh, you should use GNUmakefile-cross:
$ make -f GNUmakefile-cross static dynamic cryptest.exe
clang++ -DNDEBUG -g2 -Os -fPIC -pipe -Wall -Wno-delete-non-virtual-dtor -arch armv7 -isysroot
/Applications/Xcode-5_1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
-stdlib=libc++ -c cryptlib.cpp
clang++ -DNDEBUG -g2 -Os -fPIC -pipe -Wall -Wno-delete-non-virtual-dtor -arch armv7 -isysroot
/Applications/Xcode-5_1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
-stdlib=libc++ -c cpu.cpp
clang++ -DNDEBUG -g2 -Os -fPIC -pipe -Wall -Wno-delete-non-virtual-dtor -arch armv7 -isysroot
/Applications/Xcode-5_1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
-stdlib=libc++ -c 3way.cpp
...
I thought we updated the iOS procedures when we updated the Android procedures. I'm not sure what went wrong the documentation updates.
We checked in the scripts for setenv-ios.sh, setenv-android.sh and setenv-embedded.sh in March 2016. GNUmakefile-cross was already in the library. Also see Commit a78b9dfa0840f92f, Added iOS environment and test script and Commit 22d6374ce7151ad0, Added Android and embedded environment and test script.
All you should need to do now is the following:
git clone https://github.com/weidai11/cryptopp.git
cd cryptopp
. ./setenv-ios.sh
make -f GNUmakefile-cross static dynamic cryptest.exe
...
The new/updated files will be available in the ZIP at the next Crypto++ release, which will be either 5.6.4 or 5.7.0.

linking error: "undefined reference to `pthread_atfork'" in Armadillo library

recently I updated my armadillo to version 5.200.1, but when i tried to compile my code using
g++ -std=c++11 -m64 -O3 -Wall -I. -I/opt/OpenBLAS/include -fopenmp -o code.cpp.o -c code.cpp
g++ -std=c++11 -m64 -O3 -Wall -I. -I/opt/OpenBLAS/include -fopenmp -o main.cpp.o -c main.cpp
g++ -std=c++11 -m64 -O3 -o code.cpp.o main.cpp.o -lgomp -L/opt/OpenBLAS/lib -lopenblas -larmadillo
I got error message in the final linking step
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/libarmadillo.so:
undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
make: *** [a.out] Error 1
This error appears in my machine with Ubuntu 14.04LTS + gcc 4.9.2.
The Armadillo itself is linked with OpenBLAS 0.2.14 (I followed the procedure provided by Armadillo in installation)
such error doesn't occur in my macosx laptop (the same library). It means something problems with my ubuntu machine. I tried to re-install the Armadillo 4.650.2 (this version worked before), but the same error kept appearing (now older doesn't work like before). The only thing that i did before updating those libraries were "apt-self update" and "apt-self upgrade" of my ubuntu machine
is there any suggestion to fix this problem?
I also use armadillo on Ubuntu Linux
I had the same problem first when I started to program with armadillo. For g++ I only had to add -larmadillo as command line option. such as this
g++ -O2 -o armadillo_example armadillo_example.cpp -larmadillo

License plate recogntion using OpenCV

I got a good Automatic Number Plate Recognition Project from github (https://github.com/kornelik/anpr ). In order to run this we need OpenCV and Tesseract Optical Character Recognition library (https://code.google.com/p/tesseract-ocr/). It works fine in my Ubuntu 12.04 , 32bit system.
The problem is that while I setting the same working code in another system (Ubuntu 12.04 , 32 bit) after configuring OpenCV and Tesseract it produces the following error while making the project.I am struggling to find out what is the issue
The error is
g++ -Wall -Werror -O2 -c main.cpp -o main.o
g++ -Wall -Werror -O2 -c recognizer.cpp -o recognizer.o
g++ -Wall -Werror -O2 -c conio.cpp -o conio.o
g++ -Wall -Werror -O2 -c ocr_char.cpp -o ocr_char.o
ocr_char.cpp: In constructor ‘anpr::OCRChar::Impl::Impl(const string&, const string&)’:
ocr_char.cpp:17:9: error: ‘set’ is not a member of ‘std’
ocr_char.cpp:17:18: error: expected primary-expression before ‘char’
ocr_char.cpp:17:18: error: expected ‘;’ before ‘char’
ocr_char.cpp:23:17: error: ‘goodChars’ was not declared in this scope
make: *** [ocr_char.o] Error 1
Is your code updated? On nov 2013 there was a commit to include the set header:
https://github.com/kornelik/anpr/commit/2a63fb362e6fc79ac73f172195a893b37287d3bf
The error message you got seems to be related to that.
Compiled ok on Ubuntu 14.04 64 bits.

Resources