|
I am including , again, full complier / linker output. This is for purpose of discussion , I hope I can delete it later.
Here is a full verbose output of complier and linker, note slew of "includes".
In theory #include /gtk/gtk.h should work.
If the error is flagged in IDE as " file not accessible" does it really matters if it is complier or linker error?
( The Eclipse refers to complier as "Linux GCC" then as "GCC C++ Complier" however the actuall options string starts with "g++". Semantics???)
10:50:35 **** Build of configuration Debug for project GTK_WIKI ****
make all
Building file: ../src/GTK_WIKI.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/include/gtk-3.0/gtk -O0 -g3 -Wall -c -fmessage-length=0 `pkg-config --cflags --libs gtk+-3.0` -v -MMD -MP -MF"src/GTK_WIKI.d" -MT"src/GTK_WIKI.o" -o "src/GTK_WIKI.o" "../src/GTK_WIKI.cpp"
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)
COLLECT_GCC_OPTIONS='-I' '/usr/include/gtk-3.0/gtk' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-pthread' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/at-spi2-atk/2.0' '-I' '/usr/include/at-spi-2.0' '-I' '/usr/include/dbus-1.0' '-I' '/usr/lib/x86_64-linux-gnu/dbus-1.0/include' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/gio-unix-2.0/' '-I' '/usr/include/mirclient' '-I' '/usr/include/mircore' '-I' '/usr/include/mircookie' '-I' '/usr/include/cairo' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/harfbuzz' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/atk-1.0' '-I' '/usr/include/cairo' '-I' '/usr/include/pixman-1' '-I' '/usr/include/freetype2' '-I' '/usr/include/libpng12' '-I' '/usr/include/gdk-pixbuf-2.0' '-I' '/usr/include/libpng12' '-I' '/usr/include/glib-2.0' '-I' '/usr/lib/x86_64-linux-gnu/glib-2.0/include' '-v' '-MMD' '-MP' '-MF' 'src/GTK_WIKI.d' '-MT' 'src/GTK_WIKI.o' '-o' 'src/GTK_WIKI.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -quiet -v -I /usr/include/gtk-3.0/gtk -I /usr/include/gtk-3.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gtk-3.0 -I /usr/include/gio-unix-2.0/ -I /usr/include/mirclient -I /usr/include/mircore -I /usr/include/mircookie -I /usr/include/cairo -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/pango-1.0 -I /usr/include/atk-1.0 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/freetype2 -I /usr/include/libpng12 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libpng12 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -imultiarch x86_64-linux-gnu -MMD src/GTK_WIKI.d -MF src/GTK_WIKI.d -MP -MT src/GTK_WIKI.o -dD -D_GNU_SOURCE -D_REENTRANT ../src/GTK_WIKI.cpp -quiet -dumpbase GTK_WIKI.cpp -mtune=generic -march=x86-64 -auxbase-strip src/GTK_WIKI.o -g3 -O0 -Wall -version -fmessage-length=0 -fstack-protector-strong -Wformat-security -o /tmp/ccPz2oLW.s
GNU C++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) version 5.4.0 20160609 (x86_64-linux-gnu)
compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory "/usr/include/gtk-3.0"
ignoring duplicate directory "/usr/include/pango-1.0"
ignoring duplicate directory "/usr/include/cairo"
ignoring duplicate directory "/usr/include/libpng12"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/gtk-3.0/gtk
/usr/include/gtk-3.0
/usr/include/at-spi2-atk/2.0
/usr/include/at-spi-2.0
/usr/include/dbus-1.0
/usr/lib/x86_64-linux-gnu/dbus-1.0/include
/usr/include/gio-unix-2.0/
/usr/include/mirclient
/usr/include/mircore
/usr/include/mircookie
/usr/include/cairo
/usr/include/pango-1.0
/usr/include/harfbuzz
/usr/include/atk-1.0
/usr/include/pixman-1
/usr/include/freetype2
/usr/include/libpng12
/usr/include/gdk-pixbuf-2.0
/usr/include/glib-2.0
/usr/lib/x86_64-linux-gnu/glib-2.0/include
/usr/include/c++/5
/usr/include/x86_64-linux-gnu/c++/5
/usr/include/c++/5/backward
/usr/lib/gcc/x86_64-linux-gnu/5/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) version 5.4.0 20160609 (x86_64-linux-gnu)
compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 85af4995304287cdd19cfa43cf5d6cf1
../src/GTK_WIKI.cpp: In function 'int main(int, char**)':
../src/GTK_WIKI.cpp:30:16: warning: variable 'window' set but not used [-Wunused-but-set-variable]
GtkWidget *window;
^
../src/GTK_WIKI.cpp:31:16: warning: unused variable 'label' [-Wunused-variable]
GtkWidget *label;
^
COLLECT_GCC_OPTIONS='-I' '/usr/include/gtk-3.0/gtk' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-pthread' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/at-spi2-atk/2.0' '-I' '/usr/include/at-spi-2.0' '-I' '/usr/include/dbus-1.0' '-I' '/usr/lib/x86_64-linux-gnu/dbus-1.0/include' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/gio-unix-2.0/' '-I' '/usr/include/mirclient' '-I' '/usr/include/mircore' '-I' '/usr/include/mircookie' '-I' '/usr/include/cairo' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/harfbuzz' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/atk-1.0' '-I' '/usr/include/cairo' '-I' '/usr/include/pixman-1' '-I' '/usr/include/freetype2' '-I' '/usr/include/libpng12' '-I' '/usr/include/gdk-pixbuf-2.0' '-I' '/usr/include/libpng12' '-I' '/usr/include/glib-2.0' '-I' '/usr/lib/x86_64-linux-gnu/glib-2.0/include' '-v' '-MMD' '-MP' '-MF' 'src/GTK_WIKI.d' '-MT' 'src/GTK_WIKI.o' '-o' 'src/GTK_WIKI.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
as -v -I /usr/include/gtk-3.0/gtk -I /usr/include/gtk-3.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/gtk-3.0 -I /usr/include/gio-unix-2.0/ -I /usr/include/mirclient -I /usr/include/mircore -I /usr/include/mircookie -I /usr/include/cairo -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/pango-1.0 -I /usr/include/atk-1.0 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/freetype2 -I /usr/include/libpng12 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libpng12 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include --64 -o src/GTK_WIKI.o /tmp/ccPz2oLW.s
GNU assembler version 2.26.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.26.1
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-I' '/usr/include/gtk-3.0/gtk' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-pthread' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/at-spi2-atk/2.0' '-I' '/usr/include/at-spi-2.0' '-I' '/usr/include/dbus-1.0' '-I' '/usr/lib/x86_64-linux-gnu/dbus-1.0/include' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/gio-unix-2.0/' '-I' '/usr/include/mirclient' '-I' '/usr/include/mircore' '-I' '/usr/include/mircookie' '-I' '/usr/include/cairo' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/harfbuzz' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/atk-1.0' '-I' '/usr/include/cairo' '-I' '/usr/include/pixman-1' '-I' '/usr/include/freetype2' '-I' '/usr/include/libpng12' '-I' '/usr/include/gdk-pixbuf-2.0' '-I' '/usr/include/libpng12' '-I' '/usr/include/glib-2.0' '-I' '/usr/lib/x86_64-linux-gnu/glib-2.0/include' '-v' '-MMD' '-MP' '-MF' 'src/GTK_WIKI.d' '-MT' 'src/GTK_WIKI.o' '-o' 'src/GTK_WIKI.o' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
Finished building: ../src/GTK_WIKI.cpp
Building target: GTK_WIKI
Invoking: GCC C++ Linker
g++ -v `pkg-config --cflags --libs gtk+-3.0` -o "GTK_WIKI" ./src/GTK_WIKI.o
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-pthread' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/at-spi2-atk/2.0' '-I' '/usr/include/at-spi-2.0' '-I' '/usr/include/dbus-1.0' '-I' '/usr/lib/x86_64-linux-gnu/dbus-1.0/include' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/gio-unix-2.0/' '-I' '/usr/include/mirclient' '-I' '/usr/include/mircore' '-I' '/usr/include/mircookie' '-I' '/usr/include/cairo' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/harfbuzz' '-I' '/usr/include/pango-1.0' '-I' '/usr/include/atk-1.0' '-I' '/usr/include/cairo' '-I' '/usr/include/pixman-1' '-I' '/usr/include/freetype2' '-I' '/usr/include/libpng12' '-I' '/usr/include/gdk-pixbuf-2.0' '-I' '/usr/include/libpng12' '-I' '/usr/include/glib-2.0' '-I' '/usr/lib/x86_64-linux-gnu/glib-2.0/include' '-o' 'GTK_WIKI' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/ccECrhXv.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o GTK_WIKI /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 ./src/GTK_WIKI.o -lstdc++ -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o
makefile:45: recipe for target 'GTK_WIKI' failed
./src/GTK_WIKI.o: In function `main':
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2020_228/work_228/GTK_WIKI/Debug/../src/GTK_WIKI.cpp:49: undefined reference to `gtk_window_new'
collect2: error: ld returned 1 exit status
make: *** [GTK_WIKI] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
10:50:37 Build Failed. 3 errors, 2 warnings. (took 2s.689ms)
|
|
|
|
|
|
How did you pick that up? I copied the entire output posted at the top of this thread, and
a) a search for "undefined" turned up nothing, and
b) as currently shown, the compile completes successfully!!
Doing a quick perusal of the rest of the thread, I didn't notice any further mention of exactly what was undefined.
At this point, I have no idea what the problem is, since it looks to me like the compile/link is correct - -lgtk-3 is in the link options. Maybe Eclipse is doing something odd.
Keep Calm and Carry On
|
|
|
|
|
Here is the part of actual code
#include /usr/include/gtk-3.0/gtk/gtk.h // edited so it show
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *label;
cout << "WINDOW sample code" << endl; // prints
/* Create the main, top level window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
And here is the tail of the compile / link process
./src/GTK_WIKI.o: In function `main':
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2020_228/work_228/GTK_WIKI/Debug/../src/GTK_WIKI.cpp:49: undefined reference to `gtk_window_new'
collect2: error: ld returned 1 exit status
makefile:45: recipe for target 'GTK_WIKI' failed
make: *** [GTK_WIKI] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
12:30:58 Build Failed. 3 errors, 2 warnings. (took 2s.647ms)
Any actual , constructive help to solve the problem is appreciated.
Cheers
|
|
|
|
|
It was right at the end of the build output in the previous message:
/media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2020_228/work_228/GTK_WIKI/Debug/../src/GTK_WIKI.cpp:49: undefined reference to `gtk_window_new'
collect2: error: ld returned 1 exit status
make: *** [GTK_WIKI] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
10:50:37 Build Failed. 3 errors, 2 warnings. (took 2s.689ms)
Did you search the original which did not have any errors?
I can only assume that there is an object file or library missing from the build.
[edit]
I have also tried to explain a number of times to OP that adding header files to a build has no effect on linker errors.
[/edit]
|
|
|
|
|
I need to put code from my MFC app into a C++ app for iPad. And I have read a lot to figure out what should I use to develop such a thing. Can I call your experience in order to guide me what kind of framework to use for that ? I thought the shortest way is to use a virtual machine, but I don't think that it would be possible to use virtual machine on a iPad ...
I don't developed any app for MAC OS and any extra information regarding this is useful to me.
Thank you.
|
|
|
|
|
|
Yes, but I saw there C# code, not C++ ... and I need C++, I don't know C# at all.
|
|
|
|
|
|
I want encrypt & decrypt Video file With FFMPEG oflfine mode in hard disk.
I encrypt a Video File (mp4 Extention) by ffmpeg.exe Tools by this Command:
ffmpeg -i SampleVideo_1280x720_1mb.mp4 -vcodec copy -acodec copy
-encryption_scheme cenc-aes-ctr -encryption_key
76a6c65c5ea762046bd749a2e632ccbb -encryption_kid
a7e61c373e219033c21091fa607bf3b8 SampleVideo_1280x720_1mb_encrypted.mp4
for decryption : i want decrypt and play video file (encrypted.mp4) in my player source c++ (ffmpeg base) and *now i dont wnat use decrypt file with command line with ffplay.exe *like this :
ffplay SampleVideo_1280x720_1mb_encrypted.mp4 -decryption_key
76a6c65c5ea762046bd749a2e632ccbb
how i can do decrypt with Write programing code that use FFMPEG api?
thanks in advance.
|
|
|
|
|
DARA ALAVI wrote: how i can do decrypt with Write programing code that use FFMPEG api?
Read/learn the FFMPEG api documentation.
|
|
|
|
|
I searched a lot but did not find anything.
There is no explanation on how to use it.
I did not find a sample..
|
|
|
|
|
Then use the recommended way to decrypt with ffplay.exe
|
|
|
|
|
I do not need ffplay.exe because i downloaded FFMPEG dev and i have written my own player program Which is based on FFMPEG! with QT & C++.
I dont want use ffplay.exe that exist static FFMPEG Folder. .
I want decrypt and play Encrypted File in my player program Through Programing code.
Now how to decrypt encrypted files using FFMPeg API with C++ Programing?
thanks.
|
|
|
|
|
I need to debug some code executing on top of FreeRTOS that runs on an embedded ARM processor and I have no knowledge of FreeRTOS and I was hoping someone here could please help me. Image there are two threads in the entire code, one high-priority communication bus driver and one low-priority application thread. Whenever the application wants to write, it queues a struct onto a queue and when the communication driver sees that there is a struct in the queue, it pulls the struct out and starts writing over the communication bus according to the instructions in the struct. Now, let's assume the application first wants to write 1 byte and then shortly thereafter wants to write 2 bytes and the bytes to write are located on the stack and NOT in static variables/arrays. What the recommended way to handle this? Clearly the 2nd struct would be 1 byte larger than the 1st struct, but they both need to go into the same queue.
modified 12-Jul-20 16:14pm.
|
|
|
|
|
I have had a similar issue in the past, and created a struct like this:
struct sq
{
int nbytes;
byte queueItems[1];
}
When a struct is required it is a simple matter to allocate it dynamically from the struct size plus the number of bytes to be added to the queueItems array. The nbytes item can then be filled in with the number of bytes in the array to be handled elsewhere.
|
|
|
|
|
Generally you would have a circular queue of pointers to struct on the transmission queue. You don't want to be copying data around when you don't have to and it means the transmission queue is always just a pointer that the transmission sender can check what the pointer points to. In your struct you could have for example a field which would be "size to send" and then the data. You either free the struct after sending if dynamic, or clear a flag in the struct to mark it free for reuse if using static structs.
As you are feeding two threads into one queue you will also need to put a binary semaphore on queue access.
In vino veritas
|
|
|
|
|
I am writing code for an ARM processor and compiling with GCC. I have done some C# programming and there you're allowed to declare delegates inside structures. What's the closest thing I can achieve the same thing in my ARM-project? For example, it would great if I could write a state machine like this:
typedef void (*readDataResultCallback_t)(uint8_t* readData, uint16_t sizeOfReadData);
typedef enum {
STATE1 = 0,
STATE2 = 1,
STATE3 = 2,
} stateMachineState_e;
typedef struct __attribute__((__packed__)) {
stateMachineState_e state;
uint32_t startAddr;
uint16_t numRegsToRead;
readDataResultCallback_t readDataResultCallback;
} stateMachineStep_s;
static stateMachineState_e state = STATE1;
stateMachineStep_s stateMachineSteps[3] = {
{STATE1, 10, 2, { (uint8_t* readData, uint16_t sizeOfReadData) {
if (stringCompare(readData, "AB") {
... Do stuff here...
state = STATE_2;
} else {
... Do stuff here...
state = STATE_3;
}}},
{STATE2, 20, 3, { (uint8_t* readData, uint16_t sizeOfReadData) {
if (stringCompare(readData, "ABC") {
... Do stuff here...
state = STATE_1;
} else {
... Do stuff here...
state = STATE_3;
}}},
{STATE3, 30, 4, { (uint8_t* readData, uint16_t sizeOfReadData) {
if (stringCompare(readData, "ABCD") {
... Do stuff here...
state = STATE_3;
} else {
... Do stuff here...
state = STATE_2;
}}},
}; Do I need to write my own pre-compile code interpreter/generator script that would place the anonymous code in functions outside the stateMachineStep_s array or is there something clever I can do (perhaps with macros or C++)?
modified 10-Jul-20 7:38am.
|
|
|
|
|
the
readDataResultCallback member of your structure is just a fancy pointer, either 32 or 64 bits long depending on your architecture, so it can only be initialised with the memory address of a function.
So you could have something like the following...
void OnState1(uint8_t* readData, uint16_t sizeOfReadData)
{
...
}
stateMachineStep_s stateMachineSteps[3] = {
{STATE1, 10, 2, &OnState1}
...
}
which, to be honest, is not significantly more typing. You could also use macros to generate some of the code but that comes with it's own issues.
C++11 and greater support lambda expressions which will allow you to initialise your structs with a similar syntax to your example but in that case you would have to swap your function pointer to an std::function<> type. If you don't have c++11 support the boost library offers a similar function pointer but without the nicer lambda syntax.
modified 10-Jul-20 10:24am.
|
|
|
|
|
Josh Gray2 wrote: which, to be honest, is not significantly more typing It's not a matter of typing less, it's a matter of having code that is easy to read (I expect to have arount 50-60 states).Josh Gray2 wrote: If you don't have c++11 support the boost library offers a similar function pointer but without the nicer lambda syntax. When I googled it, it seems GCC has terrific support for C++.Josh Gray2 wrote: C++11 and greater support lambda expressions which will allow you to initialise your structs with a similar syntax to your example but in that case you would have to swap your function pointer to an std::function<> type. Could someone knowledgeable in C++ please help with the syntax for the example I provided? Do I need to put it inside a C++ file or it is possible have sections of a C-file containing C++ code?
|
|
|
|
|
arnold_w wrote: Could someone knowledgeable in C++ please help with the syntax for the example I provided? Do I need to put it inside a C++ file or it is possible have sections of a C-file containing C++ code? |
You can't put C++ code inside a C file, but since C++ is (mostly) a superset of C, most C code will compile without issue. About the only thing you can't do is use a C identifier that is a C++ keyword (e.g. int new; will not compile in C++).
Depending on what you're running on your ARM, you might be able to get C# (mono) up and running on your ARM device (e.g. raspberry pi or similar).
Keep Calm and Carry On
|
|
|
|
|
There is no syntax for your example, as neither C nor C++ have such a feature. A function pointer needs to contain the address of the function to be called.
|
|
|
|
|
If you are allowed to use (a modern version of) the C++ compiler (g++ ), then something like this
#include <functional>
#include <iostream>
using namespace std;
using MyCallback = function <void(const char * p, const size_t size)>;
struct State
{
int i;
MyCallback mc;
};
State s[] =
{
{ 10, [](const char * p, size_t size ){ for (size_t n=0; n<size; ++n) cout << p[n];}}
};
int main()
{
cout << s[0].i << endl;
s[0].mc( "foo", 3);
cout << endl;
}
would work.
|
|
|
|
|
I converted my project to a C++ project (I could see that the line <nature>org.eclipse.cdt.core.ccnature got added inside my .project file) and added your code, but I get the following error message when I try to build the project:
cannot open linker script file -Wl,-Map=output.map: No such file or directory MyProject C/C++ Problem
Do you know what I'm doing wrong?
|
|
|
|
|
|