Qt 4.6.1
In the following .pro file, when I use the statement
sources = ef.cpp
I get following errors:
RInside.h: No such file or directory
Then when I replace = with := like:
sources := ef.cpp
the above error vanishes, and I get a new error:
error: undefined reference to qMain(int, char**)
From here: https://stackoverflow.com/a/448939/462608
VARIABLE = value Normal setting of a variable — values within it are
recursively expanded when the variable is used, not when it’s declaredVARIABLE := value Setting of a variable with simple expansion of the
values inside — values within it are expanded at declaration time.
I wish to understand what’s happening here, and what’s the solution.
.cpp
#include <RInside.h>
int main(int argc, char *argv[])
{
RInside R(argc, argv);
R["txt"] = "Hello, world!n";
R.parseEvalQ ("cat(txt)");
exit(0);
}
.pro
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
R_HOME := 'c:/R-2.15.1'
# Input
sources = ef.cpp
programs := $(sources:.cpp=)
## include headers and libraries for R
RCPPFLAGS := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config --cppflags)
RLDFLAGS := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config --ldflags)
RBLAS := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config BLAS_LIBS)
RLAPACK := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config LAPACK_LIBS)
## include headers and libraries for Rcpp interface classes
RCPPINCL := $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla
--slave)
RCPPLIBS := $(shell echo 'Rcpp:::LdFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave)
## include headers and libraries for RInside embedding classes
RINSIDEINCL := $(shell echo 'RInside:::CxxFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave)
RINSIDELIBS := $(shell echo 'RInside:::LdFlags()' | $(R_HOME)/bin/R $(R_ARCH) --vanilla --slave)
## compiler etc settings used in default make rules
CXX := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXX)
CPPFLAGS := -Wall $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CPPFLAGS)
#CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R $(R_ARCH)
CMD config CXXFLAGS)
QMAKE_CXXFLAGS := $(RCPPFLAGS) $(RCPPINCL) $(RINSIDEINCL) $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXXFLAGS)
LDFLAGS = -s
QMAKE_LIBS := $(RLDFLAGS) $(RBLAS) $(RLAPACK) $(RINSIDELIBS) $(RCPPLIBS)
CC := $(shell $(R_HOME)/bin/R $(R_ARCH) CMD config CXX)
nikkka Мат в 32 хода 237 / 172 / 18 Регистрация: 10.09.2009 Сообщений: 1,096 |
||||
1 |
||||
12.08.2010, 09:52. Показов 8617. Ответов 12 Метки нет (Все метки)
0 |
Programming Эксперт 94731 / 64177 / 26122 Регистрация: 12.04.2006 Сообщений: 116,782 |
12.08.2010, 09:52 |
Ответы с готовыми решениями: C:Usersqtworkqtqtbasesrcwinmainqtmain_win.cpp:97: ошибка: undefined reference to `qMain(int, char**) Ошибки в коде Qt — ошибка: undefined reference to `qMain(int, char**)’; ошибка: error: ld returned 1 exit status [Linker error] undefined reference to `sterling(int, int, int)’
Третьи сутки осваиваю функции C++, вторые сутки бьюс не на… 12 |
Заблокирован |
|
12.08.2010, 09:53 |
2 |
Может быть текст ошибки приведёшь?
0 |
Мат в 32 хода 237 / 172 / 18 Регистрация: 10.09.2009 Сообщений: 1,096 |
|
12.08.2010, 09:55 [ТС] |
3 |
undefined reference to ‘qMain(int, char**)’
0 |
Модератор 11900 / 7272 / 1721 Регистрация: 25.07.2009 Сообщений: 13,314 |
|
12.08.2010, 10:47 |
4 |
QLable *label = new QLabel(«Hello Qt!»); QLabel а не QLable — внимательнее надо быть!
1 |
Мат в 32 хода 237 / 172 / 18 Регистрация: 10.09.2009 Сообщений: 1,096 |
|
12.08.2010, 10:50 [ТС] |
5 |
QLabel а не QLable — внимательнее надо быть! фу блин, и правда… спасибо!
0 |
3211 / 1459 / 73 Регистрация: 09.08.2009 Сообщений: 3,441 Записей в блоге: 2 |
|
12.08.2010, 20:15 |
6 |
внимание!
undefined reference to ‘qMain(int, char**)’ ответ:
QLabel а не QLable — внимательнее надо быть! не замечаете несоответствия? nikkka, скажи, и что, разве ошибка линковки пропала?
1 |
бжни 2473 / 1684 / 135 Регистрация: 14.05.2009 Сообщений: 7,162 |
|
12.08.2010, 20:25 |
7 |
не замечаете несоответствия? не у одного меня паранойя
1 |
Мат в 32 хода 237 / 172 / 18 Регистрация: 10.09.2009 Сообщений: 1,096 |
|
12.08.2010, 22:08 [ТС] |
8 |
nikkka, скажи, и что, разве ошибка линковки пропала? вообще то да…
0 |
3211 / 1459 / 73 Регистрация: 09.08.2009 Сообщений: 3,441 Записей в блоге: 2 |
|
12.08.2010, 22:10 |
9 |
вообще то да… ладно. промолчу. а то как скажу!…
0 |
Мат в 32 хода 237 / 172 / 18 Регистрация: 10.09.2009 Сообщений: 1,096 |
|
12.08.2010, 22:12 [ТС] |
10 |
niXman, а ведь правда помогло.
0 |
Модератор 11900 / 7272 / 1721 Регистрация: 25.07.2009 Сообщений: 13,314 |
|
12.08.2010, 23:59 |
11 |
я понимаю, что это тоже ошибка, но ошибка линковки говорит совсем о другой причине. А вот теперь я не понял… Скопировал отсюда, поправил QLable на QLabel и всё нормально срослось… А что там ещё не так-то?
0 |
бжни 2473 / 1684 / 135 Регистрация: 14.05.2009 Сообщений: 7,162 |
|
13.08.2010, 00:07 |
12 |
easybudda, вопрос в том первоначальное написание порождало ошибку линковки? потому как оно скомпилироваться не должно было
0 |
Модератор 11900 / 7272 / 1721 Регистрация: 25.07.2009 Сообщений: 13,314 |
|
13.08.2010, 00:12 |
13 |
вопрос в том первоначальное написание порождало ошибку линковки? Ну QtCreator порой вообще очень чудно ругается — голову сломаешь, что бы это значило…
0 |
This topic has been deleted. Only users with topic management privileges can see it.
When I compiled my project,Qt Creator showed this error.I googled it,and many people say it’s because of losing main function.But I actually have main function.
main.cpp
@#include<QApplication>
#include»dialog.h»
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
dialog d;
d.show();
return app.exec();
}
@
.pro
@TEMPLATE = app
TARGET = custombutton_mine
HEADERS +=
mybutton.h
dialog.h
SOURCES +=
mybutton.cpp
dialog.cpp
main.cpp
FORMS +=
dialog.ui@
I’m getting the same error at compile time. Tried checking entire code line by line , yet can’t figure it out.
@JadeN001
How you get the same error «at run time» given that it’s a compile-time error message?
@JonB sorry its by mistake,yeah i am getting it at compile time
What OS, what Qt version, which compiler?
What do you have in your project file (.pro
)?
@kshegunov OS:windows
qt version : Qt 5.10.1 (MSVC 2015, 32 bit).
i am using sub-project for plugin implementation so my main pro file is containing only
TEMPLATE = subdirs
SUBDIRS =
Server
plugin
but i think problem is in my plugin project which is sub project of my main project.
plugin.pro
TEMPLATE = lib
CONFIG += plugin
QT += widgets
INCLUDEPATH += ../mainwindow
HEADERS +=
broadcast_plugin.h
SOURCES +=
broadcast_plugin.cpp
TARGET = $$qtLibraryTarget(broadcast_plugin)
DESTDIR = ../plugins
@JadeN001 said in Error: undefined reference to `qMain(int, char**)’:
but i think problem is in my plugin project which is sub project of my main project.
You can know — it’s a linker error and you should check the build output. Provide the relevant project file for the binary that fails to link.
@kshegunov yeah thanks..i will go through it.
- Forum
- Qt
- Newbie
- Error — undefined reference qMain
-
2nd November 2008, 02:03
#1
Error — undefined reference qMain
Its probably something simple that I overlooked, but I have never gotten this error before and I have no idea how to get past it:
c:Qt4.4.1lib/libqtmain.a(qtmain_win.o)(.text+0x156):qtmain_win.cpp: undefined reference to `qMain(int, char**)'
To copy to clipboard, switch view to plain text mode
originally, I had some classes that I wanted to put into a shared library. These classes were for QDialogs, and one of them was a QMainWindow. The reason for a ‘dialog’ being a QMainWindow was to have a tool bar on it (it is a dialog that allows the user to send an email), which doesn’t seem to be allowed for QDialogs. The reason to include the dialogs within a library, was to create a common library of dialogs that I could use in multiple programs.
The shared library compiled fine with no errors, so I am assuming that something might be wrong with the .pro file of the program that is using the library.
-
3rd November 2008, 01:25
#2
Re: Error — undefined reference qMain
ah after a few trials and errors, I figured it out.
I forgot «main.cpp» in the list of sources in my .pro file
-
22nd February 2009, 19:06
#3
Re: Error — undefined reference qMain
I’m having the same error, but when linking a file which includes main…
am I missing something?
-
22nd February 2009, 20:22
#4
Re: Error — undefined reference qMain
Well, I have had this happen a couple times since then, and it was always because of either of 2 things:
— missing or mistyping something in my .pro file
— missing or mistyping a #include command somewherewithout seeing more info about your problem/code I couldn’t say for sure an exact solution.
-
23rd February 2009, 07:54
#5
Re: Error — undefined reference qMain
actually, I’m not using .pro files and qmake, but autotools instead, and it works fine but for some files (with main function); by googling I found a similar problem was due to some include files that define «main»; it all was solved by adding this preprocessor directive before my main:
#undef main
To copy to clipboard, switch view to plain text mode
but this looks like a bug, doesn’t it?
Similar Threads
-
Replies: 60
Last Post: 4th November 2009, 14:22
-
Replies: 1
Last Post: 20th November 2007, 17:33
-
Replies: 4
Last Post: 9th October 2007, 13:41
-
Replies: 2
Last Post: 8th June 2007, 14:28
-
Replies: 9
Last Post: 25th June 2006, 19:15
Bookmarks
Bookmarks

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
- BB code is On
- Smilies are On
- [IMG] code is On
- [VIDEO] code is On
- HTML code is Off
Forum Rules
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.
|
Автор | Тема: [РЕШЕНО]помогите разобраться с ошибками(их 3)(XML) (Прочитано 1064 раз) |
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||
|
||||||