Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Compile VC++ static library for use with MASM

Featured Replies

Posted

Hi all,

I've tried unsuccessfully on several occasions to compile C code to a static library so i can use it with MASM, but every time i try, i add the lib file to a project (created just for testing) and try to compile and i get the following error message:

error LNK2001: unresolved external symbol _Function1@16

I've used extern "C" to prevent the names being decorated, but this doesnt seem to make any difference to the error, as it is identical regardless of the name being decorated or not. I've tried using stdcall, no joy. Does anybody know what needs to be done to succeed with this?

Also, i've succeeded in making a static library from a VC++ dll with Dll2Lib (an alternate approach i thought would be valid) once, but now when i try to do it with other dlls, i get the same error message as above. Does anybody have any experience with this and if so, how can i make the static libraries usable with MASM?

It would be great if anyone can help me, please.

HR,

Ghandi

Edited by ghandi

Did you try exporting your stuff simply via DEF file ?

PS: Just tried myself.. indeed worked only after disabling a sh;tload of props in the project settings :|

/edit

as I tried it myself anyway, check it out if you wanna: libby_test.7z

Edited by Ufo-Pu55y

  • Author

Thanks Ufo,

Converting your project to VS2008 must have changed something, cos i've got the same issue, but i can compile the C code from commandline, so it is just an obj file. Then i can use that obj file when linking the MASM obj and it works fine.

Because i use WinASM for an IDE, i had to find where you can edit the commandline passed to link.exe, which is in Project > Properties. It is here that i add the C obj file name and then i can build the project as per normal and it works fine.

HR,

Ghandi

  • Author

Unsure what made a difference, but now all i need to do is use:

extern "C"

{

// Function declarations go here

}

and now the compiled lib files work directly from VC++ to MASM.

The only issue i have now is that i cant compile it with runtime as part of the library, because the heap initialization isnt performed, so calls to malloc will cause a crash. Is there a way i can get the C++ runtime to initialize? Otherwise i'll just stick to using it with multithread dll because msvcrt.dll ships with XP+ anyways.

HR,

Ghandi

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.