How to solve the linking errors when using the ATOMIC functions
2009-03-13 19:14
639 查看
[How to solve the linking errors when using the ATOMIC
functions?]
When some new atomic functions
of GCC are used in the i386 platform, the linking errors maybe take place. It takes
me troubles in some time even if I have updated GCC to the latest version (GCC-4.3.3).
Herein, I will give my solution to overcome it, and share the experience with
you in the Linux OS.
[How to know whether your machine is i386?]
Please use ‘uname’ command to disclose your
hardware platform.
[What are the atomic functions?]
1. __sync_add_and_fetch()
2. __sync_sub_and_fetch()
3. __sync_lock_test_and_set()
4. __sync_add_and_fetch()
[How to compile your source codes in the i386?]
It is a critical stage to get rid
of the linking errors. Maybe you have known, these functions are provided by
GCC (Not glibc), so the special compiling option must be added at the compile
step. For example:
Do you find the RED-BOLD part? Yes, it is a key option! If you have met troubles to
link these files using atomic functions, please confirm whether ‘-march=i486’
has been added.
After compiling, are you happy? I guess
that it is true! Haha!.
[Summarization]
Open-Source is a big platform
including huge information/tools…, so the accumulation plays very important role
in the daily activities. The trivial points of knowledge should be tidied when
you have spent much time in finding the root causes. Meanwhile, if it can help freshmen
touching this field, its value is represented.
functions?]
When some new atomic functions
of GCC are used in the i386 platform, the linking errors maybe take place. It takes
me troubles in some time even if I have updated GCC to the latest version (GCC-4.3.3).
Herein, I will give my solution to overcome it, and share the experience with
you in the Linux OS.
[How to know whether your machine is i386?]
Please use ‘uname’ command to disclose your
hardware platform.
$ uname -i i386 |
1. __sync_add_and_fetch()
2. __sync_sub_and_fetch()
3. __sync_lock_test_and_set()
4. __sync_add_and_fetch()
[How to compile your source codes in the i386?]
It is a critical stage to get rid
of the linking errors. Maybe you have known, these functions are provided by
GCC (Not glibc), so the special compiling option must be added at the compile
step. For example:
gcc -o atomic.o -c -fvisibility=hidden -march=i486 -Wall -pthread -O3 -fPIC atomic.c |
link these files using atomic functions, please confirm whether ‘-march=i486’
has been added.
After compiling, are you happy? I guess
that it is true! Haha!.
[Summarization]
Open-Source is a big platform
including huge information/tools…, so the accumulation plays very important role
in the daily activities. The trivial points of knowledge should be tidied when
you have spent much time in finding the root causes. Meanwhile, if it can help freshmen
touching this field, its value is represented.
相关文章推荐
- How to solve the libmount dependency when building BSP using ptxdist
- How to solve: when using tab in gnomeTerminal , the entire screen flash,
- How to solve: when using tab in gnomeTerminal , the entire screen flash,
- How to find the log I want when using 'git log'
- Linux - How to remove the new line at the end of file when using vim
- How to solve problem caused when the CRT library and MFC libraries are linked in the wrong order
- How to solve the problem witch is the system send many emails when cron have something wrong
- How to assign the priority when using rspc_api_chain_start?
- How to output the message when using the function 'printf'
- how to solve the problem when you have chmod the directory to 777 but the apache still can not write file
- C++ How to avoid the enter key when using cin and getline
- How to solve install error ".NET Framework 2.0 is not detected." when installing VS tools SDK for GP 10.0
- How to bind to data when the DataContext is not inherited【项目】
- How to solve the problem : "You have been logged on with a temporary profile"
- windows下python如何安装模块或包? How to install package or module in windows OS when using PYTHON?
- How to discard the default animation when AP launched
- how to solve "[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!"
- Xenapp appcenter初始化报错:Errors occurred when using XAC-1 in the discovery process
- How to Persist With Your Goals When the Going Gets Tough
- How to represent ROC curve when using Cross-Validation