-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description / Steps to reproduce the issue
I recently installed a fresh msys2 system and I'm trying to build the following project:
#import <objc/objc.h>
#import <objc/runtime.h>
@interface TestObject
{
Class isa;
}
+ (id)alloc;
- (void)dealloc;
- (id)init;
@end
@implementation TestObject
+ (id)alloc
{
return class_createInstance(self, 0);
}
- (void)dealloc
{
if(self != nil)
object_dispose(self);
}
- (id)init
{
return self;
}
@end
int main(int argc, char** argv)
{
TestObject *object = [[TestObject alloc] init];
[object dealloc];
}
Call it main.m and compile it with the command:
clang -Wno-objc-root-class -o main.exe main.m -lobjc
This gives the following error:
C:/Developer/msys64/ucrt64/bin/ld: C:/Developer/msys64/tmp/main-6a5981.o:main.m:(.text+0x13c): undefined reference to `__objc_exec_class'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Expected behavior
I expected it to compile without any errors, as it did in my old msys2 installation.
Actual behavior
Instead, I get a linker error. Am I forgetting to install any packages? These are in my system (explicit):
base 2022.06-1
bison 3.8.2-5
filesystem 2025.05.08-2
flex 2.6.4-4
mingw-w64-ucrt-x86_64-clang 20.1.8-2
mingw-w64-ucrt-x86_64-flexdll 0.43-1
mingw-w64-ucrt-x86_64-libobjc2 2.2.1-3
mingw-w64-ucrt-x86_64-make 4.4.1-3
msys2-runtime 3.6.4-1
Verification
- I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)
Windows Version
MINGW64_NT-10.0-26100
MINGW environments affected
- MINGW64
- MINGW32
- UCRT64
- CLANG64
- CLANGARM64
Are you willing to submit a PR?
No! I'm not brave enough!