Creator builds acting oddly...

  • ...not sure how to put this into words, so I'll just show you the files and the result:


    #include "testsha.h"
    int main()
        return 0;


    extern int SHA256Reset();


    int SHA256Reset()
      return 0;

    When I build, I get this error:

    C:\Users\MZimmers\Qt projects\test\main.cpp:5: error: undefined reference to `SHA256Reset()'

    When I change the file testsha224-256.c to a .cpp file, do a clean, a qmake and a build, the error goes away.

    Can someone explain this behavior to me?

    Windows 10, newest version of Creator, MinGW 5.3.0.

    Thanks...this one has me cross-eyed.

  • Qt Champions 2017

    this is not a issue with qt build i feel. it issue with mixing c and cpp in same project.

  • Right you are. After sleeping on it, I did some googling and realized that the inclusion of the header file needs to be enclosed thusly:

    extern "C"
    #include testsha.h

    (There are other ways of doing this, but this is cleanest for a C header file you don't wish to edit.)

    This prevents the C++ compiler from altering (some say "mangling") the function name.

    Thanks for looking.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.