GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Feb-2006, 03:44
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Problem in running an application outside IDE


Friends,

I have built a C application using MS VC++. When i run the program directly from the IDE, it runs.
But when i double click the exe file, MS Send error report dialog box comes, and says that the application has performed an illegal operation!

Can anyone tell me what is happening here?
I have linked my file to some external libraries.
Is that the problem involved here?

I have no idea.
Thanks...
Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #2  
Old 06-Feb-2006, 04:30
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Problem in running an application outside IDE


Quote:
Originally Posted by Paramesh
I have linked my file to some external libraries.
Is that the problem involved here?

Very likely.
I encounter the same problem when running an application without the required dll's.

Kobi.
__________________
It's actually a one time thing (it just happens alot).
  #3  
Old 06-Feb-2006, 05:33
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: Problem in running an application outside IDE


Quote:
Originally Posted by kobi_hikri
Very likely.
I encounter the same problem when running an application without the required dll's.

Kobi.
But how does it run from the IDE?
The dlls are present in the computer isnt it?

Well. How do i solve this problem?

Thanks Kobi...
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #4  
Old 06-Feb-2006, 06:29
nkhambal nkhambal is offline
Regular Member
 
Join Date: Jul 2004
Location: CA USA
Posts: 315
nkhambal is a jewel in the roughnkhambal is a jewel in the rough

Re: Problem in running an application outside IDE


Look for the path that your IDE sets for searching the dynamically linked libraries. On *nix, its set using environment variable called, LD_LIBRARY_PATH. When a program runs (outside the IDE, in your case), the dynamically linked libraries are searched under the given path speficed by the LD_LIBRARY_PATH or some related variable under windows. If the libraries or DLLs are not found under these paths or if the variable is not set in your current execution space, program fails.
  #5  
Old 06-Feb-2006, 06:50
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about

Re: Problem in running an application outside IDE


Quote:
Originally Posted by Paramesh
Well. How do i solve this problem?

Simply create a library for the included files that are needed for your application.
Lets say your application resides under c:\Paramesh
So, put all the dll's under c:\Paramesh\RunTime
Now, from within your code, include the dll's from the library \RunTime
So now, your application will look one folder "Deeper" for the dll's, from it's currently being used.

Kobi.
__________________
It's actually a one time thing (it just happens alot).
  #6  
Old 06-Feb-2006, 07:27
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: Problem in running an application outside IDE


I use MS VC++ in windows. ( )

I am linking to only static libraries, I tried it in the same operating system.

I finally traced out where the error was, and i found that it was because of the memory allocation.

If i allocate only less memory, it works..
But if i try to allocate more, the error message comes up.

For example, if i have the memory allocated for 2 floats, it works..
But if i try to allocate 10 floats, it didnt work!

Well. What may be the problem now?
The files are linked correctly because it worked for less memory.
But for more memory, it didnt work.

So, it is not a linker problem i think.

Thanks for your help friends....
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #7  
Old 06-Feb-2006, 07:36
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Problem in running an application outside IDE


Hi, Paramesh.

This problem is very interesting.
Could you please give some source code - unless it is very long.
For instance, I would like to know if the floats you allocate are created in the memory space of the executable or in that of the libraries.

Thanks,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #8  
Old 06-Feb-2006, 07:52
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: Problem in running an application outside IDE


Thanks Lucian!

The source code is too long to be posted here...
I'll post a part of my source code:
CPP / C++ / C Code:
    extern int M;

    float **Image_in_Row = new float*[M];

    for(int i = 0; i < M; i++) {
        Image_in_Row[i] = new float[77760];
        std::cout<<"Memory allocated for Row: "<< (i+1) << std::endl;
    }
It only allocated the memory for the first time...
The next time, it doesnt..

Thank you..
Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #9  
Old 06-Feb-2006, 08:04
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Problem in running an application outside IDE


So, what value does M ussually have? I tried this program several times without any problem (but without any outside dependencies, either):

CPP / C++ / C Code:
const int M = 5;

int main()
{
	float **Image_in_Row = new float*[M];

	
	for(int i = 0; i < M; i++) 
	{
		Image_in_Row[i] = new float[77760];
		std::cout << "Memory allocated for Row: " << (i+1) << std::endl;
	}

	for(int i = 0; i < M; i++) 
	{
		delete Image_in_Row[i];
	}
	delete [] Image_in_Row;
	std::cin.get();
	return 0;
}
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #10  
Old 06-Feb-2006, 08:30
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,311
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Problem in running an application outside IDE


Quote:
Originally Posted by LuciWiz
So, what value does M ussually have?

A more relevant question might be: What value does M have when your program tries to allocate storage:

CPP / C++ / C Code:
   extern int M;
.
.
.
    std::cout << "M = " << M << endl; // Make the program tell you the value of M
    float **Image_in_Row = new float*[M];

    for(int i = 0; i < M; i++) {
        Image_in_Row[i] = new float[77760];
        std::cout<<"Memory allocated for Row: "<< (i+1) << std::endl;
    }

Put this kind of output statement in your actual program, not just the test loop.

See if the program thinks M is what you think it should be.

It may just happen that M is not initialized the way that you think it is.

For example, uninitialized variables may have different values in programs run from the IDE than they do when run from a command line.

Regards,

Dave
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Specified CGI Application Misbehaved by not running a complete set of HTTP Header SSS Computer Software Forum - Windows 2 16-Oct-2006 23:01
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 07:03
commands out of sync problem (c++ builder) Largowww MS Visual C++ / MFC Forum 0 28-May-2005 03:40
Help! Some basal questions about MFC xutingnjupt MS Visual C++ / MFC Forum 1 05-Dec-2004 03:38
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 07:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 02:50.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.