Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. copy class cpp and header to folder, its not visible by compiler
Forum Update on Monday, May 27th 2025

copy class cpp and header to folder, its not visible by compiler

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 82 Views
  • 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.
  • J Offline
    J Offline
    JacobNovitsky
    wrote last edited by
    #1

    I have app linked to shared library
    CTE (App) to CTL (Lib)

    I want to add new Class to shared Library which can be accessible in app, linked to the .so
    When I create new Class with Qt Creator it works and builds and runs fine
    If I just copy txt file to folder, its not visible by compiler
    What do I miss? Maybe I should affect Makefile or smth else?

    TEMPLATE = app
    CONFIG += c++17
    CONFIG -= app_bundle
    CONFIG -= qt

    LIBS += -L/home/j/CTL-Debug/debug/debug -lCtl
    INCLUDEPATH += /home/j/CTL/

    QMAKE_CXXFLAGS_WARN_ON += -Wno-unknown-pragmas -w
    QMAKE_CXXFLAGS += -Wno-ignored-qualifiers

    QMAKE_CXXFLAGS += -O0 -g

    SOURCES +=
    main.cpp
    LibraryCTL.cpp

    HEADERS +=
    LibraryCTL.h

    main.cpp
    #include </home/j/CTL/LibraryCTL.h>

    TestFn test;

    int main(int argc, char *argv[])
    {

    return 0;
    }

    LibraryCTL.h
    #pragma once
    #ifndef LIBRARYCTE_H
    #define LIBRARYCTE_H

    using namespace std;
    #include <string>

    class LibraryCTE
    {
    public:
    LibraryCTE();
    ~LibraryCTE();
    };

    #endif

    LibraryCTL.cpp
    #include </home/j/CTE/LibraryCTL.h>

    LibraryCTE::LibraryCTE()
    {

    }

    LibraryCTE::~LibraryCTE()
    {

    }

    TEMPLATE = lib
    CONFIG += c++17
    CONFIG -= app_bundle
    CONFIG -= qt

    DESTDIR = debug
    TARGET = $$DESTDIR/Ctl

    SOURCES +=
    TestFn.cpp
    LibraryCTL.cpp

    HEADERS +=
    TestFn.h
    LibraryCTL.h

    #include <LibraryCTL.h>

    LibraryCTL::LibraryCTL()
    {

    }

    LibraryCTL::~LibraryCTL()
    {

    }

    #pragma once
    #ifndef LIBRARYCTL_H
    #define LIBRARYCTL_H
    #include <TestFn.h>
    using namespace std;
    #include <string>

    class LibraryCTL
    {
    public:
    LibraryCTL();
    ~LibraryCTL();
    };

    #endif

    #include <LibraryCTL.h>

    TestFn::TestFn(){
    }

    #ifndef TESTFN_H
    #define TESTFN_H
    using namespace std;
    #include <string>
    class TestFn
    {
    public:
    TestFn();
    ~TestFn();
    };

    #endif

    jsulmJ 1 Reply Last reply
    0
    • J Offline
      J Offline
      JacobNovitsky
      wrote last edited by
      #2

      (I think it might be problem with Qt.pro file and empty/invisible/bad symbols or something like that)
      I dont believe it related to Makefile or I can't find any other settings/system files related to building process

      So I think problem must be in .pro file

      1 Reply Last reply
      0
      • J JacobNovitsky

        I have app linked to shared library
        CTE (App) to CTL (Lib)

        I want to add new Class to shared Library which can be accessible in app, linked to the .so
        When I create new Class with Qt Creator it works and builds and runs fine
        If I just copy txt file to folder, its not visible by compiler
        What do I miss? Maybe I should affect Makefile or smth else?

        TEMPLATE = app
        CONFIG += c++17
        CONFIG -= app_bundle
        CONFIG -= qt

        LIBS += -L/home/j/CTL-Debug/debug/debug -lCtl
        INCLUDEPATH += /home/j/CTL/

        QMAKE_CXXFLAGS_WARN_ON += -Wno-unknown-pragmas -w
        QMAKE_CXXFLAGS += -Wno-ignored-qualifiers

        QMAKE_CXXFLAGS += -O0 -g

        SOURCES +=
        main.cpp
        LibraryCTL.cpp

        HEADERS +=
        LibraryCTL.h

        main.cpp
        #include </home/j/CTL/LibraryCTL.h>

        TestFn test;

        int main(int argc, char *argv[])
        {

        return 0;
        }

        LibraryCTL.h
        #pragma once
        #ifndef LIBRARYCTE_H
        #define LIBRARYCTE_H

        using namespace std;
        #include <string>

        class LibraryCTE
        {
        public:
        LibraryCTE();
        ~LibraryCTE();
        };

        #endif

        LibraryCTL.cpp
        #include </home/j/CTE/LibraryCTL.h>

        LibraryCTE::LibraryCTE()
        {

        }

        LibraryCTE::~LibraryCTE()
        {

        }

        TEMPLATE = lib
        CONFIG += c++17
        CONFIG -= app_bundle
        CONFIG -= qt

        DESTDIR = debug
        TARGET = $$DESTDIR/Ctl

        SOURCES +=
        TestFn.cpp
        LibraryCTL.cpp

        HEADERS +=
        TestFn.h
        LibraryCTL.h

        #include <LibraryCTL.h>

        LibraryCTL::LibraryCTL()
        {

        }

        LibraryCTL::~LibraryCTL()
        {

        }

        #pragma once
        #ifndef LIBRARYCTL_H
        #define LIBRARYCTL_H
        #include <TestFn.h>
        using namespace std;
        #include <string>

        class LibraryCTL
        {
        public:
        LibraryCTL();
        ~LibraryCTL();
        };

        #endif

        #include <LibraryCTL.h>

        TestFn::TestFn(){
        }

        #ifndef TESTFN_H
        #define TESTFN_H
        using namespace std;
        #include <string>
        class TestFn
        {
        public:
        TestFn();
        ~TestFn();
        };

        #endif

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote last edited by
        #3

        @JacobNovitsky said in copy class cpp and header to folder, its not visible by compiler:

        If I just copy txt file to folder, its not visible by compiler

        What txt file and what folder?
        You need to add header/cpp files in the pro file, else the build system knows nothing about these files.
        https://doc.qt.io/qt-6/qmake-project-files.html#declaring-other-libraries

        And please format your code properly.

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

        1 Reply Last reply
        1
        • J Offline
          J Offline
          JacobNovitsky
          wrote last edited by
          #4

          problem caused by invisible symbols in cpp file :) thanks for reply

          1 Reply Last reply
          0
          • J JacobNovitsky has marked this topic as solved

          • Login

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