我不知道问题是什么。我正在尝试构建我的项目以供发布,但链接器抱怨没有找到外部符号。
奇怪的是我复制&粘贴从 Debug 到 Release 构建配置的所有包含路径和依赖项,并仔细检查它。
get_PC_definition()
例如在cpudefs.h
声明:
/* Return register definition of instruction pointer */
extern RegisterDefinition * get_PC_definition(Context * ctx);
这个函数有一些实现 - 我选择的是由宏控制的,所以是的,我也定义了所有必需的宏:
RegisterDefinition * get_PC_definition(Context * ctx) {
static RegisterDefinition * reg_def = NULL;
if (!context_has_state(ctx))
return NULL;
// and so on ..
return reg_def;
}
cpudefs.obj
到目前为止构建,但链接器只是嘲笑...也许我已经对错误视而不见但是就像我说的那样,我将配置从 Debug 复制到< em>发布构建配置。
我能尝试什么想法?
错误输出:
Error 43 error LNK1120: 9 unresolved externals C:\svn\AgentSib\Release\agentsib.exe agentsib
Error 31 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\registers.obj agentsib
Error 32 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\runctrl.obj agentsib
Error 34 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\symbols_cdb.obj agentsib
Error 35 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
Error 36 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\expressions.obj agentsib
Error 37 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\funccall.obj agentsib
Error 38 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\profiler_sst.obj agentsib
Error 41 error LNK2019: unresolved external symbol _BREAK_INST referenced in function _get_break_instruction C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
Error 27 error LNK2019: unresolved external symbol _cpu_bp_get_capabilities referenced in function _context_get_supported_bp_access_types C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 30 error LNK2019: unresolved external symbol _cpu_bp_on_resume referenced in function _sib_resume C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 28 error LNK2019: unresolved external symbol _cpu_bp_plant referenced in function _context_plant_breakpoint C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 29 error LNK2019: unresolved external symbol _cpu_bp_remove referenced in function _context_unplant_breakpoint C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 42 error LNK2019: unresolved external symbol _crawl_stack_frame referenced in function _trace_stack C:\svn\AgentSib\AgentSib\stacktrace.obj agentsib
Error 33 error LNK2019: unresolved external symbol _get_PC_definition referenced in function _command_get_children_cache_client C:\svn\AgentSib\AgentSib\stacktrace.obj agentsib
Error 39 error LNK2019: unresolved external symbol _ini_cpudefs_mdep referenced in function _ini_cpudefs C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
Error 40 error LNK2019: unresolved external symbol _regs_index referenced in function _get_reg_by_dwarf_id C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
修改
调用函数get_PC_definition()
static int set_debug_regs(Context * ctx, int check_ip, int * step_over_hw_bp) {
int i;
int ret;
uint32_t dr7 = 0;
ContextAddress ip = 0;
ContextExtensioni8051 * dext = EXT(ctx);
ContextExtensioni8051 * bps = EXT(context_get_group(ctx, CONTEXT_GROUP_BREAKPOINT));
RegisterDefinition *reg_def = NULL;
ret = 0;
if (check_ip) {
*step_over_hw_bp = 0;
reg_def = get_PC_definition(ctx);
ret = context_read_reg(ctx, reg_def, 0, reg_def->size, &ip);
if ( ret < 0 )
return -1;
}
return 0;
}
答案 0 :(得分:0)
这个问题&#34; Visual Studio 2010's strange "warning LNK4042"&#34;解决了我的问题。
毕竟这是编译器导致的链接器问题..
在Configuratoin Properties >> C/C++ >> Output Files >> Object File Name
下我用于两个配置$(IntDir)
,而它适用于 Debug 但不适用于 Release 。有人知道为什么吗?
将其更改为
$(IntDir)\%(RelativeDir)
是节省我一天的解决方案。