一、标准C库中的函数未定义
编译报错:
undefined reference to `__isoc99_sscanf'
undefined reference to `__isoc99_fscanf'
undefined reference to `__pow_finite'
undefined reference to `__powf_finite'
undefined reference to `__ctype_toupper_loc'
undefined reference to `__log10_finite'
undefined reference to `sklsip_clean'
undefined reference to `__fxstat64'
undefined reference to `__assert_fail'
undefined reference to `__log2f_finite'
undefined reference to `__xstat64'
undefined reference to `__ctype_b_loc'
undefined reference to `_IO_getc'
undefined reference to `__ctype_tolower_loc'
undefined reference to `__xstat'
undefined reference to `_IO_putc'
undefined reference to `__strdup'
undefined reference to `__rawmemchr'
undefined reference to `shm_open'
undefined reference to `__log_finite'
undefined reference to `__strtok_r'
undefined reference to `__fxstat'
undefined reference to `shm_unlink'
undefined reference to `__log2_finite'
undefined reference to `__exp_finite'
问题分析:编译链不对。
问题解决:更换编译链。
二、原子库中函数未定义
编译报错:
undefined reference to `__sync_fetch_and_sub_8'
undefined reference to `__sync_fetch_and_add_8'
undefined reference to `__sync_val_compare_and_swap_8'
undefined reference to `__atomic_store_8'
undefined reference to `__atomic_fetch_add_8'
问题分析:编译链中缺少原子函数的实现。
问题解决:将libatomic.c和libatomic_config.h使用对应编译链编译成库,再将libatomic.cpp和编译好的库链接到源码中。
//libatomic.c
/* Basic implementation of libatomic for GCC.
This basic implementation currently assumes everything is aligned.
Copyright (C) 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <stddef.h>
/* These defines should be defined based on configuration of what the target
supports. Changing these #defines is all that is required to use this
file. If your target supports unsigned int type of the appropriate
number of bytes, simply define it as 1. Note that for I16 you may
also have to change the type from __int128_t to int128_t if approriate.
Also note that you can expect to see warning from compiler similar to :
warning: conflicting types for built-in function ‘__atomic_compare_exchange_1’
This is expected behaviour. */
#include <libatomic_config.h>
#ifndef __LIBATOMIC_SUPPORTS_I1
#define __LIBATOMIC_SUPPORTS_I1 1
#endif
#ifndef __LIBATOMIC_SUPPORTS_I2
#define __LIBATOMIC_SUPPORTS_I2 1
#endif
#ifndef __LIBATOMIC_SUPPORTS_I4
#define __LIBATOMIC_SUPPORTS_I4 1
#endif
#ifndef __LIBATOMIC_SUPPORTS_I8
#define __LIBATOMIC_SUPPORTS_I8 1
#endif
#ifndef __LIBATOMIC_SUPPORTS_I1