Can't link using MSVC.

123 views
Skip to first unread message

Julio César Rocha

unread,
Jun 6, 2017, 7:28:58 PM6/6/17
to Folly: the Facebook Open-source LibrarY
Are there any specific instructions to build using MSVC/Visual Studio?
After creating a class that refers to 

  Class1.obj : error LNK2001: unresolved external symbol mallocx [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol rallocx [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol xallocx [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol sallocx [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol dallocx [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol sdallocx [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol nallocx [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol mallctl [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol mallctlnametomib [myproject.vcxproj]
  Class1.obj : error LNK2001: unresolved external symbol mallctlbymib [myproject.vcxproj]

Tracking the definition for those symbols, MallocImpl.cpp shows:
#ifdef _MSC_VER
// MSVC doesn't have weak symbols, so do some linker magic
// to emulate them. (the magic is in the header)
const char* mallocxWeak = nullptr;
const char* rallocxWeak = nullptr;
const char* xallocxWeak = nullptr;
const char* sallocxWeak = nullptr;
const char* dallocxWeak = nullptr;
const char* sdallocxWeak = nullptr;
const char* nallocxWeak = nullptr;
const char* mallctlWeak = nullptr;
const char* mallctlnametomibWeak = nullptr;
const char* mallctlbymibWeak = nullptr;

... but no concrete definition for mallocx, rallocx, etc.

Guo Rui

unread,
Jun 8, 2017, 12:15:29 PM6/8/17
to Folly: the Facebook Open-source LibrarY
I'm a new folly user, but as I searched yesterday,

If you're using VS2015 or VS2017, then there is an easy way to start using folly (or many other popular cpp libs) by using vcpkg:

Julio César Rocha

unread,
Jun 8, 2017, 3:08:31 PM6/8/17
to Folly: the Facebook Open-source LibrarY
Thanks! I'll give it a try.

Guo Rui

unread,
Jun 8, 2017, 8:35:56 PM6/8/17
to Folly: the Facebook Open-source LibrarY
Sure, good luck, and forgot to mention:

1. After installing vcpkg, the command to install folly is:

vcpkg --triplet x64-windows install folly

we need the --triplet flag since folly is x64 only, the install script ran for nearly 1 hour on my Windows VM, without any manual effort though.

2. Then for VS2017, or msbuild, of course only x64 build are supported if used folly.
Reply all
Reply to author
Forward
0 new messages