在Oracle Solaris 11/11.3 SPARC平台编译ICU 67.1时遭遇链接错误
Hey there, let's tackle that ICU 67.1 link error you're hitting on Oracle Solaris 11.3 SPARC with Developer Studio 12.6. That undefined symbol issue is a common gotcha with Solaris's strict linker, so let's break down what's going wrong and how to fix it.
makeconv Link Error on Solaris 11.3 SPARC Root Cause
The error uniset_getUnicode32Instance_67 being undefined boils down to two likely issues:
- Incorrect link order: Solaris's
ldlinker processes libraries in the order they're listed. If a library is placed before the object files that reference its symbols, the linker won't resolve those symbols properly. In your command,libicuuc.socomes before the.ofiles that need its symbols. - Potential 32-bit build inconsistencies: Since you specified
--with-library-bits=32, there might be a mismatch between the compiler's target architecture and the libraries you're linking against.
Step-by-Step Solutions
1. Fix the Link Order in the makeconv Makefile
Navigate to the tools/makeconv directory and edit the generated Makefile to adjust the link command:
- Locate the line that builds
makeconv(it should match the error command you shared) - Move all ICU libraries after the object files, and reorder system libraries to come first. The corrected command should look like this:
This ensures the linker sees the object files first, knows which symbols it needs, and then finds them in the libraries that follow./opt/developerstudio12.6/bin/CC -g -O4 -xlibmil -mt -std=c++11 -o ../../bin/makeconv gencnvex.o genmbcs.o makeconv.o ucnvstat.o -lpthread -lm -mt -L../../lib -licutu -licui18n -licuuc -L../../stubdata -licudata
2. Enforce Strict 32-Bit Build Configuration
Make sure every part of the build targets 32-bit explicitly. Modify your runConfigureICU command to add 32-bit flags:
./runConfigureICU --enable-debug Solaris --with-library-bits=32 --prefix=/scratch/mzishan/icu CFLAGS="-m32" CXXFLAGS="-m32 -std=c++11"
This ensures the compiler generates 32-bit code, and avoids mismatches with 64-bit system libraries.
3. Perform a Clean Rebuild
Partial builds can leave inconsistent artifacts. Wipe the previous build state and start fresh:
gmake clean rm -rf config.cache config.log # Run the updated configure command from step 2 ./runConfigureICU --enable-debug Solaris --with-library-bits=32 --prefix=/scratch/mzishan/icu CFLAGS="-m32" CXXFLAGS="-m32 -std=c++11" gmake
4. Tweak Optimization Flags (Optional)
Developer Studio's -O4 optimization can sometimes introduce unexpected symbol resolution issues. Try downgrading to -O2 by adding it to your CXXFLAGS:
./runConfigureICU --enable-debug Solaris --with-library-bits=32 --prefix=/scratch/mzishan/icu CFLAGS="-m32 -O2" CXXFLAGS="-m32 -std=c++11 -O2"
Verification
If the build succeeds, test the makeconv tool to confirm it works:
../../bin/makeconv --version
内容的提问来源于stack exchange,提问作者Mohammed Zishan

