Solved

Urgent:static and dynamic linking of c-runtime

Posted on 2004-08-03
4
196 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

691 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