Solved

Urgent:static and dynamic linking of c-runtime

Posted on 2004-08-03
4
192 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mixing C++ and C code elegantly 10 153
Trouble linking program with -lcrypt 3 141
Problem to show menu 5 87
What's the Difference Between a VI, the Command Prompt and a Shell 7 75
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now