Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get exception errors in ms visual studio 2019 before the main function #1197

Closed
GeorKous opened this issue Apr 23, 2024 · 7 comments
Closed
Labels
bug Something isn't working

Comments

@GeorKous
Copy link

I have two programs one is for testing the other is the main application. I run both in x64 the main program gets exceptions errors, the test program runs on release, but gives linker errors on debug mode:

I have the flecs::world ecs; as a global variable in a .h and .cpp file

//MainProgram.exe

On release mode:
ecs_stage_t *stage = flecs_stage_from_world(&world); //line 5279 read access violation. world was nullptr

On Debug mode:
result = (char *) ecs_os_malloc(size + 1); //line 57888 Exception thrown at 0x00... in app.exe: 0xC0000005: Access violation executing location 0x00...

//TestProgram.exe

On Debug mode:

  1. Severity Code Description Project File Line Suppression State
    Error LNK2019 unresolved external symbol _ecs_abort referenced in function "public: __cdecl flecs::query_base::query_base(struct ecs_world_t *,struct ecs_query_desc_t *)" (??0query_base@flecs@@qeaa@PEAUecs_world_t@@PEAUecs_query_desc_t@@@z) Flecs_Basic_Testing C:\Users\User\source\repos\Flecs_Basic_Testing\Flecs_Basic_Testing\Systems.obj 1

  2. Severity Code Description Project File Line Suppression State
    Error LNK2019 unresolved external symbol ecs_assert referenced in function "private: static void __cdecl flecs::::each_invoker<class public: __cdecl <lambda_1>::operator()(struct flecs::entity,struct syscomp)const '::2'::<lambda_1>,struct querycomp>::invoke_callback<struct flecs::::each_column,struct flecs::::term_ptr,0>(struct ecs_iter_t *,class public: __cdecl <lambda_1>::operator()(struct flecs::entity,struct syscomp)const '::2'::<lambda_1> const &,unsigned __int64,struct flecs::array<struct flecs::::term_ptr,1,void> &,struct flecs::::term_ptr)" (??$invoke_callback@Ueach_column@@flecs@@Uterm_ptr@23@$0A@@?$each_invoker@V<lambda_1>@?1???R1@QEBA@Uentity@flecs@@Usyscomp@@@z@Uquerycomp@@@@flecs@@CAXPEAUecs_iter_t@@aebv<lambda_1>@?1???R4@QEBA@Uentity@2@Usyscomp@@@z@KAEAU?$array@Uterm_ptr@@flecs@@$00X@2@Uterm_ptr@12@@z) Flecs_Basic_Testing C:\Users\User\source\repos\Flecs_Basic_Testing\Flecs_Basic_Testing\Systems.obj 1

3-18) Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol FLECS__EEcsPipeline Flecs_Basic_Testing C:\Users\User\source\repos\Flecs_Basic_Testing\Flecs_Basic_Testing\Systems.obj 1
3-18 are all LNK2001 errors

Any help would be appreciated

@GeorKous GeorKous added the bug Something isn't working label Apr 23, 2024
@copygirl
Copy link
Contributor

Friendly reminder: The error messages contain Markdown formatting characters so they aren't showing up as intended. You can surround them with backticks, in this case two, since the message itself contains backticks:

Error LNK2019 unresolved external symbol _ecs_abort referenced in function "public: __cdecl flecs::query_base::query_base(struct ecs_world_t *,struct ecs_query_desc_t *)" (??0query_base@flecs@@qeaa@PEAUecs_world_t@@PEAUecs_query_desc_t@@@z)

Error LNK2019 unresolved external symbol _ecs_assert referenced in function "private: static void __cdecl flecs::_::each_invoker<class `public: __cdecl <lambda_1>::operator()(struct flecs::entity,struct syscomp)const '::`2'::<lambda_1>,struct querycomp>::invoke_callback<struct flecs::_::each_column,struct flecs::_::term_ptr,0>(struct ecs_iter_t *,class `public: __cdecl <lambda_1>::operator()(struct flecs::entity,struct syscomp)const '::`2'::<lambda_1> const &,unsigned __int64,struct flecs::array<struct flecs::_::term_ptr,1,void> &,struct flecs::_::term_ptr)" (??$invoke_callback@Ueach_column@_@flecs@@Uterm_ptr@23@$0A@@?$each_invoker@V<lambda_1>@?1???R1@QEBA@Uentity@flecs@@Usyscomp@@@z@Uquerycomp@@@_@flecs@@CAXPEAUecs_iter_t@@aebv<lambda_1>@?1???R4@QEBA@Uentity@2@Usyscomp@@@z@_KAEAU?$array@Uterm_ptr@_@flecs@@$00X@2@Uterm_ptr@12@@z)

@SanderMertens
Copy link
Owner

I have the flecs::world ecs; as a global variable in a .h and .cpp file

Are you also compiling the flecs.c file? That could explain why you're getting missing symbols.

@GeorKous
Copy link
Author

GeorKous commented Apr 24, 2024

I changed both program's Properties->Configuration Properties->General->C language standard to ISO C11 standard from Default (legacy MSVC) and now the test program runs on both release and debug. However i still get the exception error in my main program at line 5279 ecs_stage_t *stage = flecs_stage_from_world(&world);

Are you also compiling the flecs.c file? That could explain why you're getting missing symbols.

If you mean if i have the flecs.c file in my project together with the flecs.h file then yes they are together in the same directory

@GeorKous
Copy link
Author

GeorKous commented Apr 27, 2024

This line of code causes an exception result = (char *) ecs_os_malloc(size + 1); inside the function ecs_vasprintf the size variable in my project is a valid 46. Should i ask in discord for help?

@SanderMertens
Copy link
Owner

Hm, that typically would mean that the OS API hasn't been initialized yet. Are you by any chance trying to call Flecs functions before creating the world? Can you share the stack trace of that crash?

@GeorKous
Copy link
Author

GeorKous commented Apr 28, 2024

0000000000000000()	Unknown
>	MagiCube-Infinity.exe!ecs_vasprintf(const char * fmt, char * args) Line 14578	C
	MagiCube-Infinity.exe!ecs_printv_(int level, const char * file, int line, const char * fmt, char * args) Line 28402	C
	MagiCube-Infinity.exe!ecs_log_(int level, const char * file, int line, const char * fmt, ...) Line 28458	C
	MagiCube-Infinity.exe!ecs_assert_log_(int err, const char * cond_str, const char * file, int line, const char * fmt, ...) Line 28599	C
	MagiCube-Infinity.exe!ecs_entity_init(ecs_world_t * world, const ecs_entity_desc_t * desc) Line 5275	C
	MagiCube-Infinity.exe!flecs::_::node_builder<flecs::system,ecs_system_desc_t,flecs::system_builder<ShaderProgram>,flecs::system_builder_i,ShaderProgram>::node_builder<flecs::system,ecs_system_desc_t,flecs::system_builder<ShaderProgram>,flecs::system_builder_i,ShaderProgram>(ecs_world_t * world, const char * name) Line 29707	C++
	MagiCube-Infinity.exe!flecs::system_builder<ShaderProgram>::system_builder<ShaderProgram>(ecs_world_t * world, const char * name) Line 30325	C++
	MagiCube-Infinity.exe!flecs::world::system<ShaderProgram>() Line 30520	C++
	MagiCube-Infinity.exe!`dynamic initializer for 'ShaderProg''() Line 4	C++
	MagiCube-Infinity.exe!_initterm(void(*)() * first, void(*)() * last) Line 22	C++
	[External Code]	

This is what the Call Stack window showed me, also thanks in advance for your time

@SanderMertens
Copy link
Owner

Closing as there's a duplicate help thread on the discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants