NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
lakeshoretest2005
Posts: 14
0 Kudos

link error cvistart.lib

Hello community,

I am new to Labwindows (using version 6.0.0).

I am trying to run an inherited project which is configured to debug setting, but the project will not successfully build.

The project has 5 files: 2 .h files, 1 .uir file, 1 .c, and 1 .fp.

When I try to run the .exe, the BUILD ERRORS window opens with the message:

Project link error.
Undefined symbol '_main' referenced in "c:\program files\national instruments\measurementstudio\cvi\bin\cvistart.lib"

I've checked the help files, online forums, and google, but can't find an answer to the solution.

Where and how do I start the debug process for this error?

Is there an editor where I can view the contents of cvistart.lib?

Is this particular error due to the "_" preceding main? I'm thinking more than likely it is something with my code. I have successfully run some of the included CVI sample projects, but others have given me errors.

Any help out there?

Thanks.

LT2005
Active Participant
bilalD
Posts: 1,697
0 Kudos

Re: link error cvistart.lib

If you are creating an exe, you need have a function main() or WinMain() defined in your application. The prototype is as follows

int main (int argc, char *argv[])
int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)

This is where the exe execution starts. Check to see if you have a main defined.

If this project was initially meant to be a dll with exported functions, change the project target settings to specify that. To do this, go to Build >> Target Type, and specify Dynamic Link Library.

Hope this helps
Bilal Durrani
NI
Active Participant
Wendy L
Posts: 696

Re: link error cvistart.lib

Hello LT2005,

The _main link error usually occurs when a main function is not declared in one of your included source files. The cvistart.lib function is throwing an error because CVI will look for a main() function as a start point for you application.

The main function might look something like:
int main(int argc, char*argv[])
{
//Your code here

}


First make sure that there is a main function in your .c file and see if that resolves the error.

Also, which shipping examples did you try running and what errors were returned?

Thanks.
Member
lakeshoretest2005
Posts: 14
0 Kudos

Re: link error cvistart.lib

Bilal and Wendy:

Thank you for responding.

It appears that I have two calls to main in the .c file found in my project. However, the call to main follows several functions. Is that a problem?

Here is the code:

#if(0) /* to create a stand-alone version of the Pwr interactive control */
void main(void)
{
/*** A Few lines of code found here; I removed to shorten this post.
}
#endif


#if(0) /* perform sw driver selftest fault insertion and verification */
void main(void)
{
/*** A Few lines of code found here; I removed to shorten this post.
}
#endif

Bilal:
Should I still attempt building this project as a .dll?

Wendy:
I will need to revisit the examples I tested and report back to you.

Thanks,

LT2005
Active Participant
Al S
Posts: 1,504
0 Kudos

Re: link error cvistart.lib

The compiler never sees a main().
#if is a preprocessor directive (a command to the compiler). It is used to conditionally select code to pass to the compiler. Code within an #if structure that is not selected does not get compiled.
#if(0) is never true, so main() is never compiled.
You need to select one of the mains and remove #if and #endif statements or change #if(0) to #if(1).
The two mains you see are alternate definitions. They are not calls to main. You program never calls main: the code starts in main automatically.
main does not need to be the first function defined in your .c file. Where it is defined is more a question of style. Many programmers place main toward the end of the source file.
Member
lakeshoretest2005
Posts: 14
0 Kudos

Re: link error cvistart.lib

Al,

You are exactly right, thank you for the response. And I realized the problem right after posting - seems so trivial now. I did as you say, replaced the zero with a 1 and the program compiled. Now I have other problems with function calls, but that is neither here nor there.

Thanks.
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page