|
Linux uses position independent code (PIC) to produce shared libraries. PIC objects can be produced with the -fPIC flag to either GCC or CLANG. More information here: fPIC option in GCC
Keep Calm and Carry On
|
|
|
|
|
Neat!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Rather interesting. worth remembering.
|
|
|
|
|
I just spent an hour screwing around with a simple dialog project. I worked on it yesterday, but today there is no dialog editor listed in the ToolBox. After an hour, and looking at other projects, I said, "elephant this." Closed the project and reopened - now it's there.
wtf. Anyone else seen this and maybe knows how to fix it (other than recycling the project)? I want my hour back.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
I've seen this or something similar before - I believe it was because I had the .rc file open in an editor window.
|
|
|
|
|
That may have been it - I'll have to try it when I get back to the other machine. Usually my experience has been that the graphical dialog editor closes when I want to open the source of the resource file.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
Did you try to open this dialog from the Resource View?
|
|
|
|
|
yes. The dialog was up in the graphical editor. Prior post may have hit on something... will have to try it later.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
I tried a few times by opening the resource file, etc. But each time I go back to the graphical dialog editor, it displays correctly.
Things that make you go hmm.
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|
|
I hope nobody gets uptight if I ask about "system" call / command.
( YES know it is NOT C /C++ question )
I realize "system" call is actually implemented by "bash script " and really have no desire
to analyze it further than that.
What I am looking for is to figure out how "system" outputs the "command" result to stdio ( I assume that ).
I am using "system" to retrieve "hcitool" commands.
I am using QTCreator and the "hcitool" commands are output to QTCreator "console".
I have been successful to redirect the "system" to temporary file and then was reading the file. Works OK.
I like to "redirect" the output (stdio ??) back to QT - bypassing the temp file.
If that is possible? ( I tried " | tee " ... no go )
I cannot see any such option while RTFM.
Here is a snippet of my current code -
I am just observing the system output on console and
like a "hard copy" in my main C++ application.
QElapsedTimer *ET = new QElapsedTimer();
ET->start();
QString command = "rfkill list";
// verify all
ui->textEdit->append("TRACE rfkill list");
int i = system(command.toStdString().c_str()); how to redirect this to "textEdit" ??
qDebug() << "The value returned by system call : " << QString::number(i);
QString elapsed = "Elapsed time rfkill list " + QString::number(ET->elapsed());
command = "hcitool rstat ";
.......
.
|
|
|
|
|
Didn't we already cover this? How do I pass command to system calll as variable? In particular see popen(3) - Linux manual page I still think that QProcess is the way to go if you're in QT land. You seem to be having difficulties getting that working - my advice would be to write as small a program as you can that uses Qprocess to do something like a directory listing, and get that working, then integrate what you learned from that to get it working in your main project.
If you insist, though, you should be able to redirect output, just like you would from the terminal command line e.g.
const char *command = "rfkill list > textEdit";
system(command)
system("rfkill list > textEdit"); In this instance, I don't see the value in constructing a QString just to then re-format it as a C string for the system command, and then calling the QString destructor.
Keep Calm and Carry On
|
|
|
|
|
Allow me to restate my objective - to learn how system "command" works and fits into my application. I will tackle QT options / objects later....final plan is to run multithreaded application with system calls or QT equivalent in background
From RTFM I understand that I should be able to option the actual commend same way as when used directly in "terminal".
So far only redirecting to (temporary ) file works.
Single option likes " >> /tmp/temp" stops output to the console. Not desired.
I should be able to add "| tee " - but obviously my syntax is wrong because it does not do...
As far as redirecting to " >> textEdit " I do not see how that could work...
And yes, I have a single test project to try all of this.
Here is my basic test code
const char *command = "rfkill list ";
outputs so console OK
qDebug() <<" system call result " << QString::number(system(command) );
command = "rfkill list >> /tmp/temp";
outputs to temporary file OK
qDebug() <<" system call result " << QString::number(system(command) );
command = "rfkill list |tee >> /tmp/temp";
no console output , may have added to test file - not checked
qDebug() <<" system call result " << QString::number(system(command) );
command = "rfkill list >> textEdit";
no output anywhere
qDebug() <<" system call result " << QString::number(system(command) );
Here is my debug / application output
TEST set data
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
2: hci1: Bluetooth
Soft blocked: no
Hard blocked: no
system call result "0"
system call result "0"
system call result "0"
system call result "0"
|
|
|
|
|
The tee command splits output the man page states
SYNOPSIS
tee [OPTION]... [FILE]... For every FILE you add to the end of the command, tee will direct stdout to the given file. So I think you want
rfkill list | tee tempFile This will send output to tempFile (in the current working directory) and send the output to the screen as well. You can test this from your terminal session.
Keep Calm and Carry On
|
|
|
|
|
|
As stupid as it sounds - what are the piece-parts of compiler output ?
I need to know where to find the library created....
...and please do not tell me that "11:19:00" is a time of creation..
Actually -
is there a "RTFM" document describing the "compiler output ?
\
11:19:00: Running steps for project HCI_VERSION_622...
11:19:00: Configuration unchanged, skipping qmake step.
11:19:00: Starting: "/usr/bin/make" -j4
/home/qy/Qt/6.2.2/gcc_64/bin/qmake -o Makefile ../HCI_VERSION_622/HCI_VERSION_622.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
rm -f libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so libHCI_VERSION_622.so.1 libHCI_VERSION_622.so.1.0
g++ -Wl,-rpath,/home/qy/Qt/6.2.2/gcc_64/lib -Wl,-rpath-link,/home/qy/Qt/6.2.2/gcc_64/lib -shared -Wl,-soname,libHCI_VERSION_622.so.1 -o libHCI_VERSION_622.so.1.0.0 main.o mainwindow_hci_v_622.o moc_mainwindow_hci_v_622.o /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Widgets.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Gui.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Concurrent.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Core.so -lpthread -lGL
ln -s libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so
ln -s libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so.1
ln -s libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so.1.0
11:19:02: The process "/usr/bin/make" exited normally.
11:19:02: Elapsed time: 00:02.
|
|
|
|
|
11:19:00: Running steps for project HCI_VERSION_622...
11:19:00: Configuration unchanged, skipping qmake step.
Boilerplate startup. As noted, no changes detected, the "qmake" step has been skipped
11:19:00: Starting: "/usr/bin/make" -j4 starting /usr/bin/make with 4 jobs (-j4)
/home/qy/Qt/6.2.2/gcc_64/bin/qmake -o Makefile ../HCI_VERSION_622/HCI_VERSION_622.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug qmake constructs a Makefile
rm -f libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so libHCI_VERSION_622.so.1 libHCI_VERSION_622.so.1.0 remove (rm) outdated project target
g++ -Wl,-rpath,/home/qy/Qt/6.2.2/gcc_64/lib -Wl,-rpath-link,/home/qy/Qt/6.2.2/gcc_64/lib -shared -Wl,-soname,libHCI_VERSION_622.so.1 -o libHCI_VERSION_622.so.1.0.0 main.o mainwindow_hci_v_622.o moc_mainwindow_hci_v_622.o /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Widgets.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Gui.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Concurrent.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Core.so -lpthread -lGL I think that's all one command line : run g++ to create the target
ln -s libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so
ln -s libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so.1
ln -s libHCI_VERSION_622.so.1.0.0 libHCI_VERSION_622.so.1.0 create some soft links, presumably needed for link name resolution for other projects that might use this library
11:19:02: The process "/usr/bin/make" exited normally.
11:19:02: Elapsed time: 00:02. Boilerplate successful completion of project creation
Keep Calm and Carry On
|
|
|
|
|
Thanks
So this is where libraries folders are ?
g++ -Wl,-rpath,/home/qy/Qt/6.2.2/gcc_64/lib -Wl,-rpath-link,
my libraries of interest
/home/qy/Qt/6.2.2/gcc_64/lib
-shared -Wl,-soname,libHCI_VERSION_622.so.1 -o libHCI_VERSION_622.so.1.0.0 main.o mainwindow_hci_v_622.o moc_mainwindow_hci_v_622.o
other libraries
/home/qy/Qt/6.2.2/gcc_64/lib/libQt6Widgets.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Gui.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Concurrent.so /home/qy/Qt/6.2.2/gcc_64/lib/libQt6Core.so -lpthread -lGL
|
|
|
|
|
The -Wl,... arguments to g++ are passed on the the linker. For details of the rpath and rpath-link arguments see here: Using LD, the GNU linker - Options
Member 14968771 wrote: -shared -Wl,-soname,libHCI_VERSION_622.so.1 -o libHCI_VERSION_622.so.1.0.0 main.o mainwindow_hci_v_622.o moc_mainwindow_hci_v_622.o
-shared : create a shared runtime -necessary for producing a shared library (DLL in windows-speak)
-Wl,-soname,libHCI... : see above document re -soname linker option
The .o files are the object files to put in the shared library
You are correct about the other libraries. They get picked up by rpath and rpath-link, so that when you use then libHCI_VERSION_6622 library, you do not have to add them to the link command line
Keep Calm and Carry On
|
|
|
|
|
I need some general /generic advise how to tackle this problem.
It is in my C++ QT code and I cannot even start to debug at the beginning of the code.
I have a "main" wrapper app / project and bunch of subprojects.
I used to be able to set breakpoint at the start of the main project - not anymore.
I have no clue from where this error comes from and how it started on perfectly working code. .
I can disable all subprojects and still get this error.
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
I am not asking for code, just some advise how to tackle this error.
|
|
|
|
|
First, make sure you're creating a debug build. Whatever IDE you're using should have a Build or Compile config section, so take a look and make sure that's set. Your IDE should have a built in link to the debugger, so just run the program in the debugger. When the error is thrown, the debugger should stop the program and allow you to examine the state of the program. If you need to use the command line, here's an example to help you get started:
$ cat bad_alloc.cpp
int main()
{
size_t lim = 2;
while(true)
{
int *arr = new int[lim];
delete[] arr;
lim *= 2;
}
return 0;
}
$
$
$ g++ -m32 -ggdb bad_alloc.cpp -o bad_alloc
$
$ gdb bad_alloc
Reading symbols from bad_alloc...
(gdb) run
Starting program: /home/ebacon/tmp/c++/bad_alloc
terminate called after throwing an instance of 'std::bad_array_new_length'
what(): std::bad_array_new_length
Program received signal SIGABRT, Aborted.
0xf7fce559 in __kernel_vsyscall ()
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.32-10.fc33.i686 libgcc-10.3.1-1.fc33.i686
(gdb)
(gdb) bt
(gdb)
(gdb)
(gdb) frame 8
8 int *arr = new int[lim];
(gdb)
(gdb)
(gdb) p lim
$1 = 536870912
(gdb) quit
A debugging session is active.
Inferior 1 [process 3076940] will be killed.
Quit anyway? (y or n) y
$
Hopefully, that's enough to get you started. If you need more, then Google is your friend.
Keep Calm and Carry On
|
|
|
|
|
Thanks very much.
Since my program is "under construction" it always runs in debug mode.
The error I am getting does not even get me to the first line of code to set brake point.
Since last major change I did was to change the entire project from QT version 5.12.12 to 6.2.2. - that is the prime suspect.
Since then I found out that I can "configure" individual project to specific version....
In theory - first project I tried it did not work...
I appreciate your post, but since my backup works I will try to find out why the "disable versions prior to xyz " does not work first.
I need only one of the subprojects to be of latest QT version.
Cheers
|
|
|
|
|
I think I need to withdrew this question.
After digesting more QT doc I realized that QProcess is NOT
starting a new thread , hence in my case of time consuming "scan" it is just
wrong to use it.
QT has a "concurrency" "feature" which does start multiple threads... ]
<pre>system("hcitool -i hci0 scan --flush ");
This "system call " works as expected - it finds nearby Bluetooth devices in allotted time - - up to 15 seconds. I use is instead of many "bluez" library derived function because it works CONSISTENTLY...
Because it blocks running thread for up to 15 seconds I like to utilize QT .
"QProcess" object.
I have it working using convoluted "bash" code
OProcess.start("/bin/sh", QStringList() << "-c" << "hcitool -i hci0 scan --flush >> /tmp/temp");
and like to utilize it WITHOUT
"bashing".
Something like this
QProcess::execute("system("hcitool -i hci0 scan --flush "));
of course it does not compile, hence I am here posting this.
Any "unbashed" suggestions would be appreciated - in C or C++ .
PS there are more options to be added to basic "hcitool" command.
modified 18-Jan-22 22:13pm.
|
|
|
|
|
The docs are pretty clear: QProcess Class | Qt Core 5.15.8 Try
QProcess::execute("hcitool", "-i chio scan --flush");
since hcitool is part of the bluez package, it almost certainly uses the bluez library to do its work. If you can get hold of the source code, you should be able to look through it and find out why they make it work the way you expect it to.
Keep Calm and Carry On
modified 18-Jan-22 17:58pm.
|
|
|
|
|
I did try "splitting " program and argument - it did not pass compiler.
Then I put all as a single parameter and it did not run at all.
<pre>OProcess.start("/bin/sh", QStringList() << "-c" << "hcitool -i hci0 scan --flush | tee >> /tmp/temp"); no tee ourput to console - not that important
qDebug() << OProcess.state(); returns "process starting" expected
qDebug() << OProcess.state(); returns "process starting" sort of expected
OProcess.waitForFinished();
qDebug() << OProcess.state(); return process not running expected
OProcess.execute("hcitool-i hci0 scan --flush >>/tmp/temp");
qDebug() << OProcess.state(); return process not running not surprised
OProcess.waitForFinished();
OProcess.state();
qDebug() << OProcess.state(); return process not running obvious
I am under the impression that "hci" was first - then "bluez" - based on "hci"
The QT implementation of bluez is missing the "--flush" option in "scan".
That keeps QT from actually scanning for devices and that is of no good....
|
|
|
|
|
I am using WebView2 for displaying html contents in my win32 application. I have parent.html in which I am providing reference of child.html like -
<frameset id="myFrmset">
<frame id="myFrm" name="frmContent" src="child.html"></frame>
</frameset>
In child.html :
<button id="samplebutton" onclick="postmessagetocode()">clickhere</button>
<script>
function postmessagetocode() {
window.chrome.webview.postmessage('clickSample');
}
</script>
In my c++ code I am loading parent.htm and want to get above message 'clickSample' in
m_webView->add_WebMessageReceived .
Issue that I am facing : by doing like above I am not getting this message in code. If I post any message from parent.html then I can get it. But if I do like from child.html then it never come to c++ code.
Is there the way to do so?
Is it something like I need to catch the message at parent.html first then post again to c++?
Thanks.
|
|
|
|