Menu

#2421 Lexilla AddStaticLexerModule link error

Bug
closed-fixed
nobody
lexilla (55)
5
2023-12-25
2023-12-13
No

I'm building Lexilla 5.2.9 with Visual Studio 2022 on Windows 11.
I link my C++ application with the static library liblexilla.lib.
I wrote a custom lexer, and I expected to be able to register it with AddStaticLexerModule(). However, I get a link error stating that it can't link this function:

1>CustomLexer.obj : error LNK2019: unresolved external symbol "void cdecl AddStaticLexerModule(class Lexilla::LexerModule )" (?AddStaticLexerModule@@YAXPEAVLexerModule@Lexilla@@@Z) referenced in function "public: static void cdecl CustomLexer::Initialise(void)" (?Initialise@CustomLexer@@SAXXZ)
1> Hint on symbols that are defined and could potentially match:
1> AddStaticLexerModule
1>x64\Debug\CustomLexer.exe : fatal error LNK1120: 1 unresolved externals

I think the problem is that AddStaticLexerModule is declared as a C++ function in Lexilla.h, but in Lexilla.cxx it is defined as an extern "C" function.
If I move the AddStaticLexerModule definition outside of the extern "C" block and rebuild liblexilla.lib, then my C++ application links successfully.

Discussion

  • Neil Hodgson

    Neil Hodgson - 2023-12-13
    • labels: --> lexilla
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2023-12-25
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB