ICU 58 undefined reference in MSYS2/MinGW64 - icu

Using instructions from
Compiling-ICU-with-MinGW
I got the following error
digitlst.o:digitlst.cpp:(.text+0x11): undefined reference to `_free_locale'
digitlst.o:digitlst.cpp:(.text+0x8fe): undefined reference to `_create_locale'
digitlst.o:digitlst.cpp:(.text+0xa20): undefined reference to `_create_locale'
collect2.exe: error: ld returned 1 exit status
My build environment:
MSYS2 with gcc version 6.3.0 (Rev1, Built by MSYS2 project)
64 Bit Toolchain: pacman -S mingw-w64-x86_64-toolchain
ICU 58.2 Sources ICU4C
I did
unzip icu4c-58_2-src.zip
cd icu/source
./runConfigureICU MinGW prefix=$PWD/../dist
make
Does anybody know how to solve this issue?
Edit: Same is with 58.1, but 57.1 works fine.

I was trying to build QT 5.8 with the latest version of ICU and this issue popped up...
I was able to build icu4c-58_2 by linking against libmsvcr100.a using x86_64-6.3.0-posix-seh-rt_v5-rev1
It appears that these functions are missing from the default libmsvcrt.a

Related

/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to ***

Running into errors when compiling Google's BoringSSL for NGINX QUIC on my Raspberry Pi 4B, with Raspberry Pi OS, aka Raspbian buster running on it.
The commands I used to compile
As what Google's document says, I used these commands:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
I've also tried to run cmake without passing -DCMAKE_BUILD_TYPE=Release.
Error output
Here's part of the error message. I'm not showing the entire output since it's too long (there are 352 lines). Tell me if the entire output is needed to solve this issue.
[ 75%] Linking CXX executable crypto_test
/usr/bin/ld: CMakeFiles/crypto_test.dir/abi_self_test.cc.o: in function `ABITest_SanityCheck_Test::TestBody()':
/usr/include/c++/8/bits/unique_ptr.h:81: undefined reference to `abi_test_trampoline'
/usr/bin/ld: CMakeFiles/crypto_test.dir/abi_self_test.cc.o: in function `ABITest_ARM_Test::TestBody()':
/usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r4'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_trampoline'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r0'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r1'
/usr/bin/ld: /usr/include/c++/8/bits/stl_construct.h:107: undefined reference to `abi_test_clobber_r2'
......
Additional information
cmake version 3.16.3
GNU Make 4.2.1
$ uname -a
Linux Kaibins-RPi 5.10.52-v8+ #1439 SMP PREEMPT Thu Jul 22 15:43:49 BST 2021 aarch64 GNU/Linux
Searched Google but I can't find any similar cases. I need help. Thanks so much.
This issue can also be found in Chromium bug tracker:https://crbug.com/boringssl/422. You can find full error output in the attachment there.
There is a boringssl package for OpenWrt which supports BCM2711 boards (the one the Raspberry Pi 4B is using). There is even a draft PR to package nginx with QUIC support. So, in principal, BoringSSL and nginx-quic work on this architecture. The BoringSSL version used in OpenWrt is from June 2021.
I have also compiled BoringSSL on Raspberry Pi OS without issues. These are the steps I documented for compiling on Debian and, from my memory, the same worked on Raspberry Pi OS:
sudo apt install cmake libpcre3-dev golang mercurial
git clone https://boringssl.googlesource.com/boringssl && cd boringssl
mkdir build && cd build
cmake ..
make -j16
cd ../..
hg clone -b quic https://hg.nginx.org/nginx-quic && cd nginx-quic
./auto/configure --with-debug --with-http_v3_module --with-cc-opt="-I../boringssl/include" --with-ld-opt="-L../boringssl/build/ssl -L../boringssl/build/crypto"
make -j16
sudo cp objs/nginx /usr/bin/nginx-quic
I can try to verify this again with a newer version if I find some time.

devtoolset-7 stl_vector.h undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'

I am currently trying compile my program on CentOS 7, and below error has occurred.
It works well with ubuntu 18.04, but it is not works with CentOS 7.
db/obj-db.o: In function `std::vector<std::string, std::allocator<std::string> >::_M_range_check(unsigned long) const':
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_vector.h:825: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
db/obj-db.o: In function `std::vector<int, std::allocator<int> >::_M_range_check(unsigned long) const':
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_vector.h:825: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
../bin/x64/libUFMatcher.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)#GLIBCXX_3.4.20'
../bin/x64/libUFMatcher.so: undefined reference to `__cxa_throw_bad_array_new_length#CXXABI_1.3.8'
collect2: error: ld returned 1 exit status
make: *** [Makefile:56: ../bin/x64/MatchingServer] Error 1
The centos 7 has a old gcc version, maybe 4.8.5. But now many libraries need a more high version. You can run below commands to use a higher gcc version
sudo yum update -y
sudo yum install centos-release-scl
sudo yum install devtoolset-8 # gcc 8 is part of this toolset
scl enable devtoolset-8 bash # make the gcc version be 8.3.1
Check whether the linked target(object/lib) is compiled with the same version of gcc.
I got the same compiling issue after I had a second version of gcc/g++ on my machine (CentOS 7). The original one was installed by yum (v4.8.5) and the other was installed from source code (v4.9.2). It looks like the manual install changes $PATH entries order in my shell, that /usr/local/bin went before the /usr/bin. So when my code compiles, it just looks for gcc/g++ which comes first from the $PATH. Since my manual installation of 4.9.2 gcc is not fully completed, there are missing libraries and its binary is under the /usr/local/bin.
Quick fix: just check your $PATH to see if it's messed up. For me, put /usr/local/bin after /usr/bin works.
# echo $PATH
/usr/sbin:/usr/bin:/root/bin:/usr/local/sbin:/usr/local/bin:...

Error: ASTConsumer.h not found

I'm using Mac to compile "rewritersample.cpp" from https://github.com/eliben/llvm-clang-samples/tree/master/src_clang with clang and I get the following error,
fatal error: 'clang/AST/ASTConsumer.h' file not found
I don't know why I'm getting this error even though I have clang installed on my Mac.
I was getting the same error and I fixed it by installing the libclang-dev library for the version of clang/llvm I was using.
On Linux with LLVM version 5.0 that was (not sure what the command is on a mac - sorry):
sudo apt-get install libclang-5.0-dev
Note that the documentation suggests that these examples are designed to be run with a version of llvm/clang that you have built from source (either by downloading a tarred release or cloning the llvm repository). I was able to get them to build exclusively from a version of LLVM and Clang I installed via my package manager. I had to set the configuration variables for the Makefile as follows:
CXX := /usr/bin/clang++
LLVM_SRC_PATH := /usr/lib/llvm-5.0
LLVM_BUILD_PATH := /usr/lib/llvm-5.0/build
LLVM_BIN_PATH := /usr/lib/llvm-5.0/bin
Again, it's probably a little different on a mac, but hopefully this can help point you in the right direction.

Trying to compile linux build of project, cannot find library

I am trying to build a project written in c++ on Linux Mint 16, using...
make -f ./Makefile
and I keep getting this error
/usr/bin/ld: cannot find -ludev
collect2: error: ld returned 1 exit status
make: *** [BINARY] Error 1
I was getting a lot more of the /usr/bin/ld: cannot find -foo, but I checked in my Makefile and, using the synaptic package manager, installed all the other necessary libraries, eliminating all but this error. I cant seem to find it anywhere, although perhaps I am not looking in the right places.
Thanks.
I had the some problem, right after updating to Linux Mint 17.1. I was trying to build an application with Qt 5 serial port module. Solved by installing: libudev-dev .
try:
sudo apt-get install udev
I don't know how to do that in synaptic, but it should be easier, right?

Can't compile cx_Freeze on a Python built from source

Here's my situation. I'm trying to package a game for Linux (on Ubuntu 13.04) written in Python 3.3 via cx_Freeze. Fine. I installed it via sudo apt-get install cx-freeze. Even though it installed, it didn't show up. So it's the Python 2 version. Fine. I then downloaded the source code from the website and tried to compile it with python3 ./setup.py build. This is where things fall apart. I get this error from the compiler:
/usr/bin/ld: cannot find -lpython3.3
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
I'm using Python 3.3.2, which I compiled from source. Any tips?
Reposting as an answer:
In general, I'd recommend using the Python packages from your distribution, which are already compiled in a way that cx_Freeze can work with. In Ubuntu, you can install python3 and python3-dev.
If you need to compile your own Python interpreter, then you'll need to compile it with a shared library, like this:
./configure --enable-shared
There are more instructions on compiling in the CPython devguide.

Resources