找回密码
 注册
Simdroid-非首页
查看: 149|回复: 1

[3. Fortran] 【求助】有个问题?

[复制链接]
wangjian78413 该用户已被删除
发表于 2004-4-28 22:10:00 | 显示全部楼层 |阅读模式 来自 山西太原
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2004-4-29 04:29:20 | 显示全部楼层 来自 美国

回复: 【求助】有个问题?

Simdroid开发平台
6FNO子程序中的变量D找不到定义。请参见CVF帮助如下:
  
Linker Tools Error LNK2001
  1. unresolved external symbol "symbol"
复制代码

  
Code will generate this error message if it references something (like a function, variable, or label) that the linker cannot find in all the libraries and object files it searches. In general, there are two reasons this error occurs: what the code asks for doesn't exist (the symbol is spelled incorrectly or uses the wrong case, for example), or the code asks for the wrong thing (you are using mixed versions of the libraries; some from one version of the product, others from another version).
  
Depending on the calling convention used, an at sign (@) and a decimal number may be appended to the symbol name (see ATTRIBUTES Properties and Calling Conventions).
  
Numerous kinds of coding and build errors can cause LNK2001. Several specific causes are listed below, and some have more detailed explanations.
  
Coding Problems:
  
1. In Fortran programs, some of the causes of the LNK2001 message can be one of the following:
  
a. Calling a routine with a different number of arguments or the wrong argument types than it was declared. If an argument count mismatch is intentional, then use the Fortran OPTIONAL attribute (an explicit interface is required), or use !DEC$ ATTRIBUTES C to give the called routine the C attribute (this must be specified both in the calling routine and in the called routine). For more information, see the Programmer's Guide section on mixed-language programming.
  
b. Unresolved references to Visual Fortran library routine names can be caused by omitting the appropriate USE statement required by that routine. For example, calling the TRACEBACKQQ routine requires the USE DFLIB statement and DLGINIT requires USE DFLOGM. Similarly, a specific USE statement is needed to call IMSL routines and a specific INCLUDE statement is needed to call CXML routines.
  
c. Unresolved references to _WinMain@16 can be caused by specifying a project type as Fortran Windows for a traditional application (Fortran Windows applications require a WinMain function declaration and interface). In this case, create a new Fortran project with the correct project type (such as Fortran Console), copy the files to the new project directory, and add them to the new project (see Defining Your Project).
  
d. If the routine you are calling is a Win32 API routine, you may need to specify its library in Link tab, Object/Library modules field in the Project Settings dialog box (click Settings in the Project menu). To see which library is required, read the routines description and click on QuickView in the Platform SDK documentation (see Calling Win32 Routines and the Visual Fortran Windows Module).  
  
2. Mismatched case in your code or module-definition (.DEF) file can cause LNK2001. For example, if you named a variable "var1" in one C++ source file and tried to access it as "VAR1" in another, you would receive this error. The solution is to exactly match the case of the symbol in all references.
  
3. A project that uses function inlining yet defines the functions in a .CPP file rather than in the header file can cause LNK2001.
  
4. If you are using C++, make sure to use extern "C" when calling a C function from a C++ program. By using extern "C" you force the use of the C naming convention. Be aware of compiler switches like /Tp or /Tc that force a file to be compiled as a C (/Tc) or C++ (/Tp) file no matter what the filename extension, or you may get different function names than you expect.
  
5. Attempting to reference functions or data that don't have external linkage causes LNK2001. In C++, inline functions and const data have internal linkage unless explicitly specified as extern.
  
6. A missing function body or variable will cause LNK2001. Having just a function prototype or extern declaration will allow the compiler to continue without error, but the linker will not be able to resolve your call to an address or reference to a variable because there is no function code or variable space reserved.
  
7. Name decoration incorporates the parameters of a function into the final decorated function name. Calling a function with parameter types that do not match those in the function declaration may cause LNK2001.
  
8. Incorrectly included prototypes will cause the compiler to expect a function body that is not provided. If you have both a class and non-class implementation of a function F, beware of C++ scope-resolution rules.
  
8. When using C++, make sure that you include the implementation of a specific function for a class and not just a prototype in the class definition.
  
9. Attempting to call a pure virtual function from the constructor or destructor of an abstract base class will cause LNK2001 since by definition a pure virtual function has no base class implementation.
  
10. Only global functions and variables are public.  
Functions declared with the static modifier by definition have file scope. Static variables have the same limitation. Trying to access any static variables from outside of the file in which they are declared can result in a compile error or LNK2001.  
A variable declared within a function (a local variable) can only be used within the scope of that function.  
C++ global constants have static linkage. This is different than C. If you try to use a global constant in C++ in multiple files you get error LNK2001. One alternative is to include the const initializations in a header file and include that header in your .CPP files when necessary, just as if it was a function prototype. Another alternative is to make the variable non-constant and use a constant reference when assessing it.  
Compiling and Linking Problems:
  
The names of the run-time libraries needed at link time are included in the object file module by the compiler. If you use the /NOD (/NODEFAULTLIB) option, these libraries will not be linked into the project unless you have explicitly included them. Using /NOD will cause error LNK2001 in this case.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-11-2 05:34 , Processed in 0.030681 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表