Solved

Urgent:static and dynamic linking of c-runtime

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays 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.

747 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

12 Experts available now in Live!

Get 1:1 Help Now