Skip to content

multiple definition errors on Windows (at link time) #27

@bsergean

Description

@bsergean

I am getting errors like this when include libnoise.hpp in multiple source (cpp) files in my project (https://github.com/machinezone/IXWebSocket)

Example file -> https://github.com/machinezone/IXWebSocket/blob/ac9710d5d6e1c3dba1c681168cca39e358ab73ef/ws/ws_redis_cli.cpp

(?grm@ansi@linenoise@@3UGRM@12@A) already defined in ws_connect.obj [D:\a\IXWebSocket\IXWebSocket\build\ws\ws.vcxproj]
ws_redis_cli.obj : error LNK2005: "struct _COORD linenoise::ansi::SavePos" (?SavePos@ansi@linenoise@@3U_COORD@@A) already defined in ws_connect.obj [D:\a\IXWebSocket\IXWebSocket\build\ws\ws.vcxproj]
ws_redis_cli.obj : error LNK2005: "int linenoise::ansi::nCharInBuffer" (?nCharInBuffer@ansi@linenoise@@3HA) already defined in ws_connect.obj [D:\a\IXWebSocket\IXWebSocket\build\ws\ws.vcxproj]
ws_redis_cli.obj : error LNK2005: "wchar_t * linenoise::ansi::ChBuffer" (?ChBuffer@ansi@linenoise@@3PA_WA) already defined in ws_connect.obj [D:\a\IXWebSocket\IXWebSocket\build\ws\ws.vcxproj]

The way I solved it is by moving the body in an implementation file, but I wonder if there's a better way.

(fix => machinezone/IXWebSocket@6ed8723)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions