Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [Solved] Linker Error
Forum Updated to NodeBB v4.3 + New Features

[Solved] Linker Error

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
19 Posts 4 Posters 4.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Charon117
    wrote on last edited by Charon117
    #1

    Hello,

    I have a linker problem. When i include "'include "SoftwareKursC.h" it gives me the error "undefined reference to function", which i believe is a linker problem. When i include the source files directly as a *.c everything works.

    This is the project: https://drive.google.com/file/d/1WSPILUyRjt3lpc13flTRzAPTJjHyEy_H/view?usp=sharing

    Can somebody tell me what i am doing wrong and what the solution to this problem is ? I wouldnt know how to manipulate the qmake file to make it work.

    1 Reply Last reply
    0
    • C Charon117

      @jsulm said in Linker Error:

      @Charon117 said in Linker Error:

      the drive link i posted contains the whole project

      I can't access it. pro file is just text, easy to post here...
      Build log: all compiler and linker calls during the build. In QtCreator see "4 Compile Output" tab at the bottom.

      Why cant you access it ?

      SoftwareKursC.pro:
      TEMPLATE = app
      CONFIG += console
      CONFIG -= app_bundle
      CONFIG -= qt

      INCLUDEPATH +=
      %TEMP%

      SOURCES +=
      ExercisesWeek1.c
      ExercisesWeek2.c
      Rechteck.c
      main.c

      HEADERS +=
      SoftwareKursC.h

      Tab4 output:
      15:10:25: Running steps for project SoftwareKursC...
      15:10:25: Configuration unchanged, skipping qmake step.
      15:10:25: Starting: "C:\Coding\Qt\Tools\mingw810_64\bin\mingw32-make.exe" -j4
      C:/Coding/Qt/Tools/mingw810_64/bin/mingw32-make -f Makefile.Debug
      mingw32-make[1]: Entering directory 'C:/Users/Name/Desktop/Neuer Ordner/build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug'
      gcc -c -fno-keep-inline-dllexport -g -Wall -Wextra -Wextra -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -I..\SoftwareKursC -I. -I%TEMP% -IC:\Coding\Qt\5.15.2\mingw81_64\mkspecs\win32-g++ -o debug\main.o ..\SoftwareKursC\main.c
      ..\SoftwareKursC\main.c: In function 'inputSales':
      ..\SoftwareKursC\main.c:18:25: warning: unused parameter 'ABC' [-Wunused-parameter]
      void inputSales(double* ABC){
      ^
      ..\SoftwareKursC\main.c: In function 'readText':
      ..\SoftwareKursC\main.c:106:9: warning: unused variable 'symbol' [-Wunused-variable]
      int symbol = getchar();
      ^
      ~
      ..\SoftwareKursC\main.c:104:20: warning: unused parameter 'smallLettersCount' [-Wunused-parameter]
      void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
      ~^
      ~~~~~~~~~~
      ..\SoftwareKursC\main.c:104:44: warning: unused parameter 'capitalLettersCount' [-Wunused-parameter]
      void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
      ~^~~~~~~~~~~~~~~
      ..\SoftwareKursC\main.c:104:70: warning: unused parameter 'whiteSpaceCount' [-Wunused-parameter]
      void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
      ~^~~~~~~~~~~
      ..\SoftwareKursC\main.c: In function 'main':
      ..\SoftwareKursC\main.c:136:19: warning: format '%ld' expects a matching 'long int' argument [-Wformat=]
      printf("%ld" );
      ^
      ..\SoftwareKursC\main.c:136:19: warning: format '%ld' expects a matching 'long int' argument [-Wformat=]
      ..\SoftwareKursC\main.c: In function 'Exercise':
      ..\SoftwareKursC\main.c:74:5: warning: 'i' is used uninitialized in this function [-Wuninitialized]
      for(int i; i < count;){
      ^

      g++ -Wl,-subsystem,console -mthreads -o debug\SoftwareKursC.exe debug/main.o
      debug/main.o: In function main': C:\Users\\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:114: undefined reference to ExercisesWeek2'
      C:\Users\Name\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:116: undefined reference to `ExercisesWeek1'
      collect2.exe: error: ld returned 1 exit status
      mingw32-make[1]: *** [Makefile.Debug:68: debug/SoftwareKursC.exe] Error 1
      mingw32-make[1]: Leaving directory 'C:/Users/Name/Desktop/Neuer Ordner/build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug'
      mingw32-make: *** [Makefile:45: debug] Error 2
      15:10:26: The process "C:\Coding\Qt\Tools\mingw810_64\bin\mingw32-make.exe" exited with code 2.
      Error while building/deploying project SoftwareKursC (kit: Desktop Qt 5.15.2 MinGW 64-bit)
      When executing step "Make"
      15:10:26: Elapsed time: 00:01.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #16

      @Charon117 said in Linker Error:

      INCLUDEPATH +=
      %TEMP%

      Remove these two lines.

      For some reason only main.c file is built. Did you try a complete rebuild:

      • Delete build folder
      • Run qmake
      • Build

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Apart from the fact that you seem to use qmake to create a makefile - what's the relation to Qt here?
        What exact error message do you get?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        C 1 Reply Last reply
        0
        • M Offline
          M Offline
          mchinand
          wrote on last edited by
          #3

          @Charon117 said in Linker Error:

          When i include the source files directly as a *.c everything works.

          You either have to include the source files in your project or specify in your project file that you will be linking to that library and specifying the location of the library. Can you post your project file?

          1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            Apart from the fact that you seem to use qmake to create a makefile - what's the relation to Qt here?
            What exact error message do you get?

            C Offline
            C Offline
            Charon117
            wrote on last edited by
            #4

            @Christian-Ehrlicher said in Linker Error:

            Apart from the fact that you seem to use qmake to create a makefile - what's the relation to Qt here?
            What exact error message do you get?

            I dont know. I dont know where to begin troubleshooting this. If i wouldnt use qt creator i would simply write make main.o ExercisesWeek1.o etc ..., but since i use qt creator i use qmake, and i wouldnt know how to manipulate qmake to do what i want.

            I posted the exact error message. "undefined reference to insert any function of any source file used in main here"

            @mchinand said in Linker Error:

            @Charon117 said in Linker Error:

            When i include the source files directly as a *.c everything works.

            You either have to include the source files in your project or specify in your project file that you will be linking to that library and specifying the location of the library. Can you post your project file?

            I did include them, and i dont have a library. They are all .c files made into .o files which the linker than cant seem to find to compile.

            The drive link includes the whole project, including the pro file. Can you see it ?

            The more i think about this the more I am of the oppinion that qmake never creates the .o files for the other source files.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #5

              I still don't see a relation to Qt here except that you use an IDE which is built with Qt. I also don't get a linker error. If you need the documentation for qmake you can look here but your pro file is correct.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              C 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                I still don't see a relation to Qt here except that you use an IDE which is built with Qt. I also don't get a linker error. If you need the documentation for qmake you can look here but your pro file is correct.

                C Offline
                C Offline
                Charon117
                wrote on last edited by
                #6

                @Christian-Ehrlicher said in Linker Error:

                I still don't see a relation to Qt here except that you use an IDE which is built with Qt. I also don't get a linker error. If you need the documentation for qmake you can look here but your pro file is correct.

                Which leaves me hanging to where the problem is. Is there something else i can provide to troubleshoot this ?

                Christian EhrlicherC 1 Reply Last reply
                0
                • C Charon117

                  @Christian-Ehrlicher said in Linker Error:

                  I still don't see a relation to Qt here except that you use an IDE which is built with Qt. I also don't get a linker error. If you need the documentation for qmake you can look here but your pro file is correct.

                  Which leaves me hanging to where the problem is. Is there something else i can provide to troubleshoot this ?

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  @Charon117 said in Linker Error:

                  Is there something else i can provide to troubleshoot this ?

                  Post the correct error message and the compiler you use.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  C 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    @Charon117 said in Linker Error:

                    Is there something else i can provide to troubleshoot this ?

                    Post the correct error message and the compiler you use.

                    C Offline
                    C Offline
                    Charon117
                    wrote on last edited by Charon117
                    #8

                    @Christian-Ehrlicher said in Linker Error:

                    @Charon117 said in Linker Error:

                    Is there something else i can provide to troubleshoot this ?

                    Post the correct error message and the compiler you use.

                    C:\Users\Name\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug..\SoftwareKursC\main.c:114: error: undefined reference to ExercisesWeek2' debug/main.o: In function main':
                    C:\Users\Name\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:114: undefined reference to `ExercisesWeek2'

                    ExercisesWeek2() is the first function that is called in main.

                    Compiler is MingW 64 bit, version 7.3 i believe.!

                    Unbenannt6.png

                    jsulmJ 1 Reply Last reply
                    0
                    • C Charon117

                      @Christian-Ehrlicher said in Linker Error:

                      @Charon117 said in Linker Error:

                      Is there something else i can provide to troubleshoot this ?

                      Post the correct error message and the compiler you use.

                      C:\Users\Name\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug..\SoftwareKursC\main.c:114: error: undefined reference to ExercisesWeek2' debug/main.o: In function main':
                      C:\Users\Name\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:114: undefined reference to `ExercisesWeek2'

                      ExercisesWeek2() is the first function that is called in main.

                      Compiler is MingW 64 bit, version 7.3 i believe.!

                      Unbenannt6.png

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      @Charon117 said in Linker Error:

                      ExercisesWeek2() is the first function that is called in main.

                      And where is it defined? As the error messages says linker can't find its definition. Means: you either did not implement ExercisesWeek2, or you do not link the lib/object file containing ExercisesWeek2.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      C 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @Charon117 said in Linker Error:

                        ExercisesWeek2() is the first function that is called in main.

                        And where is it defined? As the error messages says linker can't find its definition. Means: you either did not implement ExercisesWeek2, or you do not link the lib/object file containing ExercisesWeek2.

                        C Offline
                        C Offline
                        Charon117
                        wrote on last edited by
                        #10

                        @jsulm said in Linker Error:

                        @Charon117 said in Linker Error:

                        ExercisesWeek2() is the first function that is called in main.

                        And where is it defined? As the error messages says linker can't find its definition. Means: you either did not implement ExercisesWeek2, or you do not link the lib/object file containing ExercisesWeek2.

                        The question clarifies that replacing the header file *.h with the appropriate *.c files works. This is the content of the header file:

                        #ifndef SOFTWAREKURSC_H
                        #define SOFTWAREKURSC_H

                        void Rechteck(void);
                        int ExercisesWeek1(void);
                        int ExercisesWeek2(void);

                        #endif // SOFTWAREKURSC_H

                        and Christian Ehrlicher already said that it compiles for him on his system and that the pro file is correct.

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          Charon117
                          wrote on last edited by
                          #11

                          OK, so i am convinced by now that this is a compiler error, because MingW seems to generate the other *.o objects in %TEMP%, wherever that is. If that is correct, how do i point the Qt Creator to check for %TEMP% ? Also, im not convinced that the object files are actually named correctly ?

                          So i am not even sure if the compiler generates the object files, where they are, how they are named and how to tell Qt Creator where to find them.

                          jsulmJ 1 Reply Last reply
                          0
                          • C Charon117

                            OK, so i am convinced by now that this is a compiler error, because MingW seems to generate the other *.o objects in %TEMP%, wherever that is. If that is correct, how do i point the Qt Creator to check for %TEMP% ? Also, im not convinced that the object files are actually named correctly ?

                            So i am not even sure if the compiler generates the object files, where they are, how they are named and how to tell Qt Creator where to find them.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #12

                            @Charon117 said in Linker Error:

                            i am convinced by now that this is a compiler error

                            "undefined reference to" - is a linker error.

                            Please post the pro file and the whole build log of a complete rebuild.

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            C 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @Charon117 said in Linker Error:

                              i am convinced by now that this is a compiler error

                              "undefined reference to" - is a linker error.

                              Please post the pro file and the whole build log of a complete rebuild.

                              C Offline
                              C Offline
                              Charon117
                              wrote on last edited by
                              #13

                              @jsulm said in Linker Error:

                              @Charon117 said in Linker Error:

                              i am convinced by now that this is a compiler error

                              "undefined reference to" - is a linker error.

                              Please post the pro file and the whole build log of a complete rebuild.

                              the drive link i posted contains the whole project. Can you see it ?

                              I dont know what the whole build log is, or where to find it, but i posted a picture here

                              Unbenannt6.png

                              jsulmJ 1 Reply Last reply
                              0
                              • C Charon117

                                @jsulm said in Linker Error:

                                @Charon117 said in Linker Error:

                                i am convinced by now that this is a compiler error

                                "undefined reference to" - is a linker error.

                                Please post the pro file and the whole build log of a complete rebuild.

                                the drive link i posted contains the whole project. Can you see it ?

                                I dont know what the whole build log is, or where to find it, but i posted a picture here

                                Unbenannt6.png

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #14

                                @Charon117 said in Linker Error:

                                the drive link i posted contains the whole project

                                I can't access it. pro file is just text, easy to post here...
                                Build log: all compiler and linker calls during the build. In QtCreator see "4 Compile Output" tab at the bottom.

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                C 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @Charon117 said in Linker Error:

                                  the drive link i posted contains the whole project

                                  I can't access it. pro file is just text, easy to post here...
                                  Build log: all compiler and linker calls during the build. In QtCreator see "4 Compile Output" tab at the bottom.

                                  C Offline
                                  C Offline
                                  Charon117
                                  wrote on last edited by
                                  #15

                                  @jsulm said in Linker Error:

                                  @Charon117 said in Linker Error:

                                  the drive link i posted contains the whole project

                                  I can't access it. pro file is just text, easy to post here...
                                  Build log: all compiler and linker calls during the build. In QtCreator see "4 Compile Output" tab at the bottom.

                                  Why cant you access it ?

                                  SoftwareKursC.pro:
                                  TEMPLATE = app
                                  CONFIG += console
                                  CONFIG -= app_bundle
                                  CONFIG -= qt

                                  INCLUDEPATH +=
                                  %TEMP%

                                  SOURCES +=
                                  ExercisesWeek1.c
                                  ExercisesWeek2.c
                                  Rechteck.c
                                  main.c

                                  HEADERS +=
                                  SoftwareKursC.h

                                  Tab4 output:
                                  15:10:25: Running steps for project SoftwareKursC...
                                  15:10:25: Configuration unchanged, skipping qmake step.
                                  15:10:25: Starting: "C:\Coding\Qt\Tools\mingw810_64\bin\mingw32-make.exe" -j4
                                  C:/Coding/Qt/Tools/mingw810_64/bin/mingw32-make -f Makefile.Debug
                                  mingw32-make[1]: Entering directory 'C:/Users/Name/Desktop/Neuer Ordner/build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug'
                                  gcc -c -fno-keep-inline-dllexport -g -Wall -Wextra -Wextra -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -I..\SoftwareKursC -I. -I%TEMP% -IC:\Coding\Qt\5.15.2\mingw81_64\mkspecs\win32-g++ -o debug\main.o ..\SoftwareKursC\main.c
                                  ..\SoftwareKursC\main.c: In function 'inputSales':
                                  ..\SoftwareKursC\main.c:18:25: warning: unused parameter 'ABC' [-Wunused-parameter]
                                  void inputSales(double* ABC){
                                  ^
                                  ..\SoftwareKursC\main.c: In function 'readText':
                                  ..\SoftwareKursC\main.c:106:9: warning: unused variable 'symbol' [-Wunused-variable]
                                  int symbol = getchar();
                                  ^
                                  ~
                                  ..\SoftwareKursC\main.c:104:20: warning: unused parameter 'smallLettersCount' [-Wunused-parameter]
                                  void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
                                  ~^
                                  ~~~~~~~~~~
                                  ..\SoftwareKursC\main.c:104:44: warning: unused parameter 'capitalLettersCount' [-Wunused-parameter]
                                  void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
                                  ~^~~~~~~~~~~~~~~
                                  ..\SoftwareKursC\main.c:104:70: warning: unused parameter 'whiteSpaceCount' [-Wunused-parameter]
                                  void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
                                  ~^~~~~~~~~~~
                                  ..\SoftwareKursC\main.c: In function 'main':
                                  ..\SoftwareKursC\main.c:136:19: warning: format '%ld' expects a matching 'long int' argument [-Wformat=]
                                  printf("%ld" );
                                  ^
                                  ..\SoftwareKursC\main.c:136:19: warning: format '%ld' expects a matching 'long int' argument [-Wformat=]
                                  ..\SoftwareKursC\main.c: In function 'Exercise':
                                  ..\SoftwareKursC\main.c:74:5: warning: 'i' is used uninitialized in this function [-Wuninitialized]
                                  for(int i; i < count;){
                                  ^

                                  g++ -Wl,-subsystem,console -mthreads -o debug\SoftwareKursC.exe debug/main.o
                                  debug/main.o: In function main': C:\Users\\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:114: undefined reference to ExercisesWeek2'
                                  C:\Users\Name\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:116: undefined reference to `ExercisesWeek1'
                                  collect2.exe: error: ld returned 1 exit status
                                  mingw32-make[1]: *** [Makefile.Debug:68: debug/SoftwareKursC.exe] Error 1
                                  mingw32-make[1]: Leaving directory 'C:/Users/Name/Desktop/Neuer Ordner/build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug'
                                  mingw32-make: *** [Makefile:45: debug] Error 2
                                  15:10:26: The process "C:\Coding\Qt\Tools\mingw810_64\bin\mingw32-make.exe" exited with code 2.
                                  Error while building/deploying project SoftwareKursC (kit: Desktop Qt 5.15.2 MinGW 64-bit)
                                  When executing step "Make"
                                  15:10:26: Elapsed time: 00:01.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • C Charon117

                                    @jsulm said in Linker Error:

                                    @Charon117 said in Linker Error:

                                    the drive link i posted contains the whole project

                                    I can't access it. pro file is just text, easy to post here...
                                    Build log: all compiler and linker calls during the build. In QtCreator see "4 Compile Output" tab at the bottom.

                                    Why cant you access it ?

                                    SoftwareKursC.pro:
                                    TEMPLATE = app
                                    CONFIG += console
                                    CONFIG -= app_bundle
                                    CONFIG -= qt

                                    INCLUDEPATH +=
                                    %TEMP%

                                    SOURCES +=
                                    ExercisesWeek1.c
                                    ExercisesWeek2.c
                                    Rechteck.c
                                    main.c

                                    HEADERS +=
                                    SoftwareKursC.h

                                    Tab4 output:
                                    15:10:25: Running steps for project SoftwareKursC...
                                    15:10:25: Configuration unchanged, skipping qmake step.
                                    15:10:25: Starting: "C:\Coding\Qt\Tools\mingw810_64\bin\mingw32-make.exe" -j4
                                    C:/Coding/Qt/Tools/mingw810_64/bin/mingw32-make -f Makefile.Debug
                                    mingw32-make[1]: Entering directory 'C:/Users/Name/Desktop/Neuer Ordner/build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug'
                                    gcc -c -fno-keep-inline-dllexport -g -Wall -Wextra -Wextra -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -I..\SoftwareKursC -I. -I%TEMP% -IC:\Coding\Qt\5.15.2\mingw81_64\mkspecs\win32-g++ -o debug\main.o ..\SoftwareKursC\main.c
                                    ..\SoftwareKursC\main.c: In function 'inputSales':
                                    ..\SoftwareKursC\main.c:18:25: warning: unused parameter 'ABC' [-Wunused-parameter]
                                    void inputSales(double* ABC){
                                    ^
                                    ..\SoftwareKursC\main.c: In function 'readText':
                                    ..\SoftwareKursC\main.c:106:9: warning: unused variable 'symbol' [-Wunused-variable]
                                    int symbol = getchar();
                                    ^
                                    ~
                                    ..\SoftwareKursC\main.c:104:20: warning: unused parameter 'smallLettersCount' [-Wunused-parameter]
                                    void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
                                    ~^
                                    ~~~~~~~~~~
                                    ..\SoftwareKursC\main.c:104:44: warning: unused parameter 'capitalLettersCount' [-Wunused-parameter]
                                    void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
                                    ~^~~~~~~~~~~~~~~
                                    ..\SoftwareKursC\main.c:104:70: warning: unused parameter 'whiteSpaceCount' [-Wunused-parameter]
                                    void readText(int *smallLettersCount, int *capitalLettersCount, int *whiteSpaceCount){
                                    ~^~~~~~~~~~~
                                    ..\SoftwareKursC\main.c: In function 'main':
                                    ..\SoftwareKursC\main.c:136:19: warning: format '%ld' expects a matching 'long int' argument [-Wformat=]
                                    printf("%ld" );
                                    ^
                                    ..\SoftwareKursC\main.c:136:19: warning: format '%ld' expects a matching 'long int' argument [-Wformat=]
                                    ..\SoftwareKursC\main.c: In function 'Exercise':
                                    ..\SoftwareKursC\main.c:74:5: warning: 'i' is used uninitialized in this function [-Wuninitialized]
                                    for(int i; i < count;){
                                    ^

                                    g++ -Wl,-subsystem,console -mthreads -o debug\SoftwareKursC.exe debug/main.o
                                    debug/main.o: In function main': C:\Users\\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:114: undefined reference to ExercisesWeek2'
                                    C:\Users\Name\Desktop\Neuer Ordner\build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug/../SoftwareKursC/main.c:116: undefined reference to `ExercisesWeek1'
                                    collect2.exe: error: ld returned 1 exit status
                                    mingw32-make[1]: *** [Makefile.Debug:68: debug/SoftwareKursC.exe] Error 1
                                    mingw32-make[1]: Leaving directory 'C:/Users/Name/Desktop/Neuer Ordner/build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug'
                                    mingw32-make: *** [Makefile:45: debug] Error 2
                                    15:10:26: The process "C:\Coding\Qt\Tools\mingw810_64\bin\mingw32-make.exe" exited with code 2.
                                    Error while building/deploying project SoftwareKursC (kit: Desktop Qt 5.15.2 MinGW 64-bit)
                                    When executing step "Make"
                                    15:10:26: Elapsed time: 00:01.

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #16

                                    @Charon117 said in Linker Error:

                                    INCLUDEPATH +=
                                    %TEMP%

                                    Remove these two lines.

                                    For some reason only main.c file is built. Did you try a complete rebuild:

                                    • Delete build folder
                                    • Run qmake
                                    • Build

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    C 1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mchinand
                                      wrote on last edited by
                                      #17

                                      You have to escape (add a backslash, \) the newlines so the list of source files will be treated as a single input line. See the SOURCES example here: https://doc.qt.io/qt-5/qmake-project-files.html#variables

                                      Christian EhrlicherC 1 Reply Last reply
                                      0
                                      • M mchinand

                                        You have to escape (add a backslash, \) the newlines so the list of source files will be treated as a single input line. See the SOURCES example here: https://doc.qt.io/qt-5/qmake-project-files.html#variables

                                        Christian EhrlicherC Offline
                                        Christian EhrlicherC Offline
                                        Christian Ehrlicher
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #18

                                        I really wonder why you upload a project but then don't use the pro-file which is in there which is correct...

                                        TEMPLATE = app
                                        CONFIG += console
                                        CONFIG -= app_bundle
                                        CONFIG -= qt
                                        
                                        SOURCES += \
                                                ExercisesWeek1.c \
                                                ExercisesWeek2.c \
                                                Rechteck.c \
                                                main.c
                                        
                                        HEADERS += \
                                            SoftwareKursC.h
                                        

                                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                        Visit the Qt Academy at https://academy.qt.io/catalog

                                        1 Reply Last reply
                                        0
                                        • jsulmJ jsulm

                                          @Charon117 said in Linker Error:

                                          INCLUDEPATH +=
                                          %TEMP%

                                          Remove these two lines.

                                          For some reason only main.c file is built. Did you try a complete rebuild:

                                          • Delete build folder
                                          • Run qmake
                                          • Build
                                          C Offline
                                          C Offline
                                          Charon117
                                          wrote on last edited by
                                          #19

                                          @jsulm said in Linker Error:

                                          @Charon117 said in Linker Error:

                                          INCLUDEPATH +=
                                          %TEMP%

                                          Remove these two lines.

                                          For some reason only main.c file is built. Did you try a complete rebuild:

                                          • Delete build folder
                                          • Run qmake
                                          • Build

                                          Ok, so the weirdest thing happened. It works now.

                                          No clue how that happened, or what i did to change it. But ... lol ... check this out.

                                          I delete the whole build folder, eg.
                                          build-SoftwareKursC-Desktop_Qt_5_15_2_MinGW_64_bit-Debug

                                          Then i compile with Qt Creator, and i only use #include *.c files. Then i comment out the *.c includes and enable the *.h includes. This leads us to exactly the error i described.

                                          Another delete later:
                                          I compile this time with *.h files and then change them to *.c files. I get a completely different linker error, but a linker error nonetheless.

                                          Another delete:
                                          I only compile with *.h includes and it works. No changing afterwards.

                                          Another delete:
                                          I only compile with *.c includes and it works. No changing afterwards.

                                          Conclusion:
                                          Changing compilation from *.h to *.c includes leads to linker errors, as well as changes from *.c to *.h includes. Deleting the build folder in both cases is the solution.

                                          What kind of clusterfucking mindblowing error is this ?

                                          Thanks for the help, i guess i will mark this as solved. Thanks to @jsulm for suggesting the correct solution. I will make a note that in case of mysterious bugs deleting the build folder is priority number one. If somebody has an explanation of why this is happening they can add it as another post.

                                          Thank you all for participating in this discussion.

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved