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

CMakeFiles/ddcui.dir/src/main/monitor.cpp.o: In function `Monitor::Monitor(DDCA_Display_Info*, int)' #28

Open
gadefox opened this issue Jul 15, 2021 · 9 comments
Labels

Comments

@gadefox
Copy link

gadefox commented Jul 15, 2021

I'm getting an error msg (see bellow). Any idea?
Configuration: Ubuntu 18.04, ddutils 1.1.0 (successfully built), Qt5.15.2 (qt515webengine, qt515tools submodules w/ dependencies into /opt/qt515)

CMakeFiles/ddcui.dir/src/main/monitor.cpp.o: In function Monitor::Monitor(DDCA_Display_Info*, int)': monitor.cpp:(.text+0x29): undefined reference to vtable for Monitor'
monitor.cpp:(.text+0x96): undefined reference to Monitor::metaObject() const' CMakeFiles/ddcui.dir/src/main/monitor.cpp.o: In function Monitor::~Monitor()':
monitor.cpp:(.text+0x14c): undefined reference to `vtable for Monitor'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/ddcui.dir/build.make:912: ddcui] Error 1
make[1]: *** [CMakeFiles/Makefile2:124: CMakeFiles/ddcui.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

@rockowitz
Copy link
Owner

First, I assume you're building from branch 0.2.0-dev, which will soon be released. The master branch is ancient.

If class Monitor lacks a vtable something has gotten out of sync in the build.

My script for running cmake contains the following lines to ensure that stale values and cached files are not used:

rm CMakeCache.txt
# if sudo make uninstall has been run, files CMakeFiles/uninsall.dir/ depend.internal and depend.make will be owned by root, only root can erase:
sudo rm -r CMakeFiles

@gadefox
Copy link
Author

gadefox commented Jul 17, 2021

In this case please upload the ddcutil dev branch too, because now I'm getting an error that the function ‘ddca_add_trace_groups’ was not declared in this scope. Thanks.

@rockowitz
Copy link
Owner

Use ddcutil branch 1.1.1-dev, which is the current development branch.

@gadefox
Copy link
Author

gadefox commented Jul 19, 2021

No difference.. Could be this problem caused by an Q_OBJECT(?) - I can't find the implementation of all these functions.

@rockowitz
Copy link
Owner

On a hunch that there are 2 definitions of class Monitor at compilation time, I have replaced all forward declarations "class Monitor" in header files with "include base/monitor.h", and uploaded the changes to branch 0.2.0-dev.
Whether or not the changes solve the problem, please submit the make output. Thanks.

@gadefox
Copy link
Author

gadefox commented Jul 22, 2021

Your change doesn't solve the problem, but I moved the "monitor" header file, updated all #includes and everything is fine now. Why don't you use qmake instead of cmake? This problem is poorly documented, most users don't have it because the header files are automatically processed by moc if they are in the same folder as the associated cpp. The following link could help you. The header files have to be added to the project using an add_executable or add_library statement. If this is not done, automoc won't parse the files.

@rockowitz
Copy link
Owner

You are quite right about the vtable problem being the result of monitor.h not being processed by the MOC. I owe you an apology for your effort. I forgot that the problem had been addressed over 2 years ago, albeit with a hack, by adding a symbolic link from src/main/monitor.h to src/base/monitor.h. See file src/main/NOTES.TXT. Did the symbolic link get lost when you downloaded the source? If so, how did you download it? As you point out, using set_executable is a more proper way to address the problem.

Why is monitor.h located in src/base, not src/main with monitor.cpp? For clarity. I try to make the dependencies of source directories form a directed graph.

Why cmake and not qmake? Initially both were implemented. I chose to focus on cmake because it is more generally used. If someone wants to bring ddcui.pro up to production level quality I am amenable to distributing it as well. (ddcui.pro currently exists only in my source tree, not on github.)

Regards,
Sanford

@gadefox
Copy link
Author

gadefox commented Jul 30, 2021

Yes, I can see your NOTES, although it doesn't solve the problem - I'm getting the same linking error.. I need to build the latest Qt5 before further testing and I'll let you know..

ren@local:~/.build/gcc-11.2.0/build$ ls -la ~/.build/ddcui-0.2.0-dev/src/main/monitor.h
-rwxrwxrwx 1 ren ren 17 júl 21 06:10 /home/ren/.build/ddcui-0.2.0-dev/src/main/monitor.h

ren@local: ~/.build/gcc-11.2.0/build$ ln -sf ~/.build/ddcui-0.2.0-dev/src/base/monitor.h /home/ren/.build/ddcui-0.2.0-dev/src/main/monitor.h

ren@local:~/.build/gcc-11.2.0/build$ ls -la ~/.build/ddcui-0.2.0-dev/src/main/monitor.h
lrwxrwxrwx 1 ren ren 51 júl 30 21:42 /home/ren/.build/ddcui-0.2.0-dev/src/main/monitor.h -> /home/ren/.build/ddcui-0.2.0-dev/src/base/monitor.h

I downloaded the code using git..

@rockowitz
Copy link
Owner

The latest updates to branch 0.2.0-dev add src/base/monitor.h to the source file list for set_executable(), and eliminate the symbolic link hack from src/main/monitor.h to src/base/monitor.h.

Please rerun cmake (and of course make) and let me know if ddcui builds cleanly. If not, submit the output of cmake and make VERBOSE=1 as attachments, which will hopefully give a clue as to how your environment differs from mine.

Thank you.

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

No branches or pull requests

2 participants