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

error LNK2019: unresolved external symbol __imp_realloc referenced in function cpArrayPush #201

Open
futurelucas4502 opened this issue Jan 19, 2021 · 1 comment

Comments

@futurelucas4502
Copy link

futurelucas4502 commented Jan 19, 2021

So disclaimer I don't really know what I'm doing :)

So I downloaded the .tgz file from your website extracted it then extracted the tar file

I then opened up the msvc folder and vs2015 and then into chipmunk I don't have visual studio installed but i do have the build tools so i retargeted the vcxproj file and then built it using msbuild chipmunk.vcxproj

I then took all the files in the x64 -> debug folder and moved them to a folder called bin in the project i'm making then grabbed the include folder as well then moved the chipmunk.lib file into the right place and made a simple project using CSFML and Chipmunk and tried to run it in vs code and got the following console output:

Starting build...
Build finished with errors(s):
main.c
Microsoft (R) Incremental Linker Version 14.28.29333.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:main.exe 
/debug 
/MACHINE:x64 
"/out:C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial/bin/main.exe" 
"C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial/externals/lib/csfml-audio.lib" 
"C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial/externals/lib/csfml-graphics.lib" 
"C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial/externals/lib/csfml-network.lib" 
"C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial/externals/lib/csfml-system.lib" 
"C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial/externals/lib/csfml-window.lib" 
"C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial/externals/lib/chipmunk.lib" 
main.obj 
   Creating library C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial\bin\main.lib and object C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial\bin\main.exp
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpHashSet.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpSpaceComponent.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpArray.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpSpaceHash.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpBBTree.obj)'
LINK : warning LNK4217: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpBody.obj)' in function 'cpBodyAlloc'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpShape.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpSpace.obj)'
LINK : warning LNK4286: symbol 'calloc' defined in 'libucrt.lib(calloc.obj)' is imported by 'chipmunk.lib(cpSpaceStep.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpSpatialIndex.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpHashSet.obj)'
LINK : warning LNK4217: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpSpaceComponent.obj)' in function 'cpBodySleepWithGroup'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpArray.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpSpaceHash.obj)'
LINK : warning LNK4217: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpBBTree.obj)' in function 'cpBBTreeReindexObject'
LINK : warning LNK4217: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpBody.obj)' in function 'cpBodyFree'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpShape.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpSpace.obj)'
LINK : warning LNK4286: symbol 'free' defined in 'libucrt.lib(free.obj)' is imported by 'chipmunk.lib(cpSpaceStep.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpSpatialIndex.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpArbiter.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpHashSet.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpSpaceComponent.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpCollision.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpSpaceHash.obj)'
LINK : warning LNK4217: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpBBTree.obj)' in function 'cpBBTreeReindex'
LINK : warning LNK4217: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpBody.obj)' in function 'cpBodySanityCheck'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpShape.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpSpace.obj)'
LINK : warning LNK4286: symbol 'abort' defined in 'libucrt.lib(abort.obj)' is imported by 'chipmunk.lib(cpSpaceStep.obj)'
LINK : warning LNK4217: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'chipmunk.lib(cpSpace.obj)' in function 'printf'
LINK : warning LNK4217: symbol '__acrt_iob_func' defined in 'libucrt.lib(_file.obj)' is imported by 'chipmunk.lib(chipmunk.obj)' in function 'cpAreaForPoly'
LINK : warning LNK4217: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'chipmunk.lib(cpSpace.obj)' in function '_vfprintf_l'
LINK : warning LNK4286: symbol '__stdio_common_vfprintf' defined in 'libucrt.lib(output.obj)' is imported by 'chipmunk.lib(chipmunk.obj)'
LINK : warning LNK4217: symbol 'qsort' defined in 'libucrt.lib(qsort.obj)' is imported by 'chipmunk.lib(cpBBTree.obj)' in function 'partitionNodes'
chipmunk.lib(cpArray.obj) : error LNK2019: unresolved external symbol __imp_realloc referenced in function cpArrayPush
chipmunk.lib(cpSpaceHash.obj) : error LNK2019: unresolved external symbol __imp_floor referenced in function cpSpaceHashSegmentQuery
C:\Users\Student\Documents\Programming\CSFML+Chipmunk Tutorial\bin\main.exe : fatal error LNK1120: 2 unresolved externals

The terminal process terminated with exit code: -1.

Terminal will be reused by tasks, press any key to close it.

I'm not 100% sure what's going on here so I'm hoping someone can help me
My tasks.json file looks like this:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe build active file",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/I${fileDirname}/externals/include",
                "${fileDirname}/externals/lib/csfml-audio.lib",
                "${fileDirname}/externals/lib/csfml-graphics.lib",
                "${fileDirname}/externals/lib/csfml-network.lib",
                "${fileDirname}/externals/lib/csfml-system.lib",
                "${fileDirname}/externals/lib/csfml-window.lib",
                "${fileDirname}/externals/lib/chipmunk.lib",
                "${file}",
                "/link",
                "/MACHINE:x64",
                "/out:${fileDirname}/bin/${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

this is my code:

#include <SFML/Graphics.h>
#include <chipmunk/chipmunk.h>
#define PI 3.14

cpFloat RadiansToDegrees(cpFloat radians)
{
    cpFloat degrees = radians * 180 / PI;
    return degrees;
}

int main(void)
{
    sfRenderWindow *window;
    sfCircleShape *ball;
    sfVector2f ball_middle = {40, 40};
    sfVector2f sfml_ball_pos = {0, 0};
    ball = sfCircleShape_create();
    sfCircleShape_setFillColor(ball, sfRed);
    sfCircleShape_setRadius(ball, 40.0);
    sfCircleShape_setOrigin(ball, ball_middle);
    sfVideoMode mode = {600, 600, 24};
    sfEvent event;

    window = sfRenderWindow_create(mode, "SFML Chipmunk Test", sfResize | sfClose, NULL);

    cpFloat chipmunk_angle;
    float sfml_angle;
    cpVect gravity = cpv(0, 0.8);
    cpSpace *space = cpSpaceNew();
    cpSpaceSetGravity(space, gravity);
    cpShape *ground = cpSegmentShapeNew(cpSpaceGetStaticBody(space), cpv(200, 400), cpv(600, 390), 0);
    cpShapeSetFriction(ground, 0.7);
    cpSpaceAddShape(space, ground);
    cpFloat radius = 40;
    cpFloat mass = 0.5;
    cpFloat moment = cpMomentForCircle(mass, 0, radius, cpvzero);
    cpBody *ballBody = cpSpaceAddBody(space, cpBodyNew(mass, moment));
    cpBodySetPosition(ballBody, cpv(500, 40));
    cpShape *ballShape = cpSpaceAddShape(space, cpCircleShapeNew(ballBody, radius, cpvzero));
    cpShapeSetFriction(ballShape, 0.7);
    cpFloat timeStep = 1.0 / 60.0;
    cpFloat time = 0;
    cpVect chipmunk_ball_pos;
    cpVect chipmunk_ball_vel;
    while (sfRenderWindow_isOpen(window))
    {
        /*This processes the events*/
        while (sfRenderWindow_pollEvent(window, &event))
        {
            if (event.type == sfEvtClosed)
            {
                puts("Closing render window.");
                sfRenderWindow_close(window);
            }
        }
        chipmunk_ball_pos = cpBodyGetPosition(ballBody);
        chipmunk_ball_vel = cpBodyGetVelocity(ballBody);
        chipmunk_angle = cpBodyGetAngle(ballBody);
        sfml_angle = RadiansToDegrees(chipmunk_angle);
        sfml_ball_pos.x = chipmunk_ball_pos.x;
        sfml_ball_pos.y = chipmunk_ball_pos.y;
        sfCircleShape_setPosition(ball, sfml_ball_pos);

        sfCircleShape_setRotation(ball, sfml_angle);
        sfRenderWindow_drawCircleShape(window, ball, NULL);
        sfRenderWindow_display(window);
        sfRenderWindow_clear(window, sfBlack);
        cpSpaceStep(space, timeStep);
        time += timeStep;
    }
    cpShapeFree(ballShape);
    cpBodyFree(ballBody);
    cpShapeFree(ground);

    sfCircleShape_destroy(ball);
    sfRenderWindow_destroy(window);
    return 0;
}
@futurelucas4502
Copy link
Author

Update: I downloaded Visual Studio 2019 and copied my project into Visual Studio 2019 with all the chipmunk files I'd previously compiled with msbuild and it runs fine so now I'm even more confused any help would be appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant