开发者

"error LNK2001: unresolved external symbol" [duplicate]

This question already has answers here: 开发者_开发百科 What is an undefined reference/unresolved external symbol error and how do I fix it? (39 answers) Closed 5 years ago.

I have a problem with my program in VC++ 2008. When I compile it, the following errors are listed. I spent a lot of time on the groups.google.com to find the reason, but no comment helped me. Does anybody knows what the problem is? Thanks.

error LNK2001: unresolved external symbol "long rfl_xref_id" (?rfl_xref_id@@3JA)
error LNK2001: unresolved external symbol "struct obj_name * pat_objname_list" (?pat_objname_list@@3PAUobj_name@@A)
error LNK2001: unresolved external symbol "struct obj_name * pat_recall_objname_list" (?pat_recall_objname_list@@3PAUobj_name@@A)
error LNK2001: unresolved external symbol "wchar_t * rfl_unresolved_xref_tag" (?rfl_unresolved_xref_tag@@3PA_WA)
error LNK2001: unresolved external symbol "struct ref_pages * rfl_pages" (?rfl_pages@@3PAUref_pages@@A)
error LNK2001: unresolved external symbol "short rfl_use_regen_id" (?rfl_use_regen_id@@3FA)
error LNK2001: unresolved external symbol "long rfl_regen_id" (?rfl_regen_id@@3JA)
error LNK2001: unresolved external symbol "unsigned short rfl_list_status" (?rfl_list_status@@3GA)
error LNK2001: unresolved external symbol "unsigned short rfl_inst_hdr_page" (?rfl_inst_hdr_page@@3GA)
error LNK2001: unresolved external symbol "unsigned short rfl_inst_hdr_ptr" (?rfl_inst_hdr_ptr@@3GA)
error LNK2001: unresolved external symbol "unsigned short rfl_inst_obj" (?rfl_inst_obj@@3GA)
error LNK2001: unresolved external symbol "short rfl_instance_level" (?rfl_instance_level@@3FA)
error LNK2001: unresolved external symbol "short rfl_access_mode" (?rfl_access_mode@@3FA)
error LNK2001: unresolved external symbol "long rfl_select_ref_offset" (?rfl_select_ref_offset@@3JA)
error LNK2001: unresolved external symbol "long rfl_edit_ref_id" (?rfl_edit_ref_id@@3JA)
error LNK2001: unresolved external symbol "long rfl_add_att_offset" (?rfl_add_att_offset@@3JA)
error LNK2001: unresolved external symbol "short rfl_adding_ent_data" (?rfl_adding_ent_data@@3FA)
error LNK2001: unresolved external symbol "long rfl_xref_def_inst_ukey" (?rfl_xref_def_inst_ukey@@3JA)
error LNK2001: unresolved external symbol "long rfl_xref_def_ukey" (?rfl_xref_def_ukey@@3JA)
error LNK2001: unresolved external symbol "long rfl_instance_ukey" (?rfl_instance_ukey@@3JA)
error LNK2001: unresolved external symbol "long rfl_ref_id" (?rfl_ref_id@@3JA)
error LNK2001: unresolved external symbol "unsigned short rfl_next_page_num" (?rfl_next_page_num@@3GA)
error LNK2001: unresolved external symbol "unsigned short rfl_num_pages" (?rfl_num_pages@@3GA)
error LNK2001: unresolved external symbol "unsigned short rfl_page_size" (?rfl_page_size@@3GA)
error LNK2001: unresolved external symbol "struct ref_pages * rfl_cur_page" (?rfl_cur_page@@3PAUref_pages@@A)
error LNK2001: unresolved external symbol "struct ref_def_map * rfl_recall_map" (?rfl_recall_map@@3PAUref_def_map@@A)
error LNK2001: unresolved external symbol "struct ref_xref_image * rfl_image_list" (?rfl_image_list@@3PAUref_xref_image@@A)
error LNK2001: unresolved external symbol "struct ref_xref_refresh * rfl_refresh_info" (?rfl_refresh_info@@3PAUref_xref_refresh@@A)
error LNK2001: unresolved external symbol "short * rfl_form_status" (?rfl_form_status@@3PAFA)
error LNK2001: unresolved external symbol "short rfl_num_forms" (?rfl_num_forms@@3FA)
error LNK2001: unresolved external symbol "long rfl_recall_start_id" (?rfl_recall_start_id@@3JA)
error LNK2001: unresolved external symbol "long rfl_recall_end_id" (?rfl_recall_end_id@@3JA)
error LNK2001: unresolved external symbol "struct ref_pages rfl_begin_add_page" (?rfl_begin_add_page@@3Uref_pages@@A)
error LNK2001: unresolved external symbol "long rfl_add_length" (?rfl_add_length@@3JA)
error LNK2001: unresolved external symbol "struct ref_pages rfl_found_page" (?rfl_found_page@@3Uref_pages@@A)
error LNK2001: unresolved external symbol "short rfl_scan_status" (?rfl_scan_status@@3FA)
error LNK2001: unresolved external symbol "struct ref_pages rfl_scan_info" (?rfl_scan_info@@3Uref_pages@@A)
error LNK2001: unresolved external symbol "struct ref_recall_xrefs * rfl_xref_list" (?rfl_xref_list@@3PAUref_recall_xrefs@@A)
error LNK2001: unresolved external symbol "struct ref_xref_image * rfl_recall_image_list" (?rfl_recall_image_list@@3PAUref_xref_image@@A)
error LNK2001: unresolved external symbol "struct ref_xref_image * rfl_found_image" (?rfl_found_image@@3PAUref_xref_image@@A)

I have included the "intdef.h" file which contents the definition of all the above external symbol. Intdef.h contains:

extern struct ref_pages *rfl_pages;
extern struct ref_pages *rfl_cur_page;
extern struct ref_pages rfl_begin_add_page;
extern struct ref_pages rfl_scan_info;
extern struct ref_pages rfl_found_page;
extern struct ref_def_map *rfl_recall_map;
extern struct ref_select_info *rfl_select;
extern struct ref_recall_xrefs *rfl_xref_list;
extern struct ref_xref_image *rfl_image_list;
extern struct ref_xref_image *rfl_found_image;
extern struct ref_xref_image *rfl_recall_image_list;
extern struct ref_xref_refresh *rfl_refresh_info;
extern unsigned short rfl_page_size;
extern unsigned short rfl_num_pages;
extern unsigned short rfl_next_page_num;
extern unsigned short rfl_inst_obj;
extern unsigned short rfl_inst_hdr_ptr;
extern unsigned short rfl_inst_hdr_page;
extern unsigned short rfl_list_status;
extern short rfl_adding_ent_data;
extern short rfl_scan_status;
extern short rfl_access_mode;
extern short rfl_instance_level;
extern short rfl_redraw_layer;
extern long rfl_add_length;
extern long rfl_ref_id;
extern long rfl_edit_ref_id;
extern long rfl_recall_start_id;
extern long rfl_recall_end_id;
extern long rfl_import_ref_id;
extern long rfl_import_xref_id;
extern long rfl_xref_id;
extern long rfl_instance_ukey;
extern long rfl_xref_def_ukey;
extern long rfl_xref_def_inst_ukey;
extern long rfl_add_att_offset;
extern long rfl_select_ref_offset;
extern long rfl_regen_id;
extern double *rfl_extents;
extern _TCHAR **rfl_ref_names;
extern short rfl_use_regen_id;
extern short rfl_ref_cntr;
extern short rfl_num_forms;
extern short *rfl_form_status;
extern _TCHAR *rfl_xref_fpath;
extern _TCHAR *rfl_xref_name;
extern _TCHAR *rfl_xref_ref_name;
extern _TCHAR *rfl_xref_ref_label;
extern _TCHAR *rfl_unresolved_xref_tag;
extern _TCHAR rfl_tran_is_iso;
extern _TCHAR rfl_doing_area;
extern int rfl_nv;
extern double *rfl_ar;
extern short rfl_regen_xref_mode;


I think the problem is with the 'extern' keyword. That keyword specifies that those values be declared somewhere else in your code. Perhaps you're missing another .c/.cpp file to compile which contains the declarations of those variables. Again, your inclusion of this header file isn't actually defining any variables -- it's just requiring that they exist somewhere else!


You've included the header but not the required library (implementation of those extern objects).

what is this library? did you download it from the web (some open source)? if yes, check that web site for .lib files (the library)


I just want to throw this out there for others who might stumble upon this post in the future.

At work I am currently upgrading projects from vs2010 (or later) to vs2012 and I happened upon this error in one of the projects. For some reason I decided to rearrange my additional dependencies in Linker -> Input -> Additional Dependencies and it fixed my error.

I don't know what changed with the linker from 2010 to 2012 but apparently it required a rearrangement of the .lib's that I was depending on.

It may not be common but if you're having this problem and there are many external dependencies it is easy enough to try this: just put the dependency that is raising this error to the end of the list and rebuild the project.

Hopefully this helps someone someday! Happy Coding!


We faced a similar problem when using the windows ras api. The issue was resolved by adding a suitable #pragma comment.


You should take a look at the post "What is an undefined reference/unresolved external symbol error and how do I fix it?"

It has a great explanation for unresolved external symbols and provides step by step debugging tips on how to resolve your error.

https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜