Solved

Urgent:static and dynamic linking of c-runtime

Posted on 2004-08-03
4
193 Views
Last Modified: 2010-04-15
I am invoking a C win32 dll from a c++ client.
And i get a crash when i try to malloc memory in the dll,something like
extern "C" __declspec (dllexport) char* CreateString ()
{
   char* pString = (char*) malloc (16);
   strcpy (pString, "Hello, world");
   return pString;
}

Now i understand that the problem may be solved in the c-runtime is linked dynamically into the dll.Since i am not conversant with MS VC++ dev environment,can someone guide as to how I confirm the following
1.whether my DLL is statically/dynamically linked to C run-time.
2.How can i convert in to link dynamically,if it is not.
0
Comment
Question by:ranadhir
4 Comments
 
LVL 4

Accepted Solution

by:
alikoank earned 38 total points
ID: 11712703
DLLs are by default linked dynamically. You can change this setting from project options.

BTW: it is a good practice to check if malloc returns null.
0
 
LVL 22

Assisted Solution

by:grg99
grg99 earned 37 total points
ID: 11714545
If possible, I'd suggest you pass in the memory from C++.  Having two heap managers running may cause considerable headaches down the line.

0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question