How can I see why libstc++ is needed - c

I'm writing a C application using openGL. All my code is C99 compliant and I'm not using c++ at all. My program links with openGL libs and SDL2.
Running ldd I get:
linux-vdso.so.1 (0x00007ffd456e0000)
libSDL2-2.0.so.0 => /lib64/libSDL2-2.0.so.0 (0x00007fccdb862000)
libGLEW.so.1.13 => /lib64/libGLEW.so.1.13 (0x00007fccdb5d7000)
libGLU.so.1 => /lib64/libGLU.so.1 (0x00007fccdb368000)
libGL.so.1 => /lib64/libGL.so.1 (0x00007fccdb0d9000)
libm.so.6 => /lib64/libm.so.6 (0x00007fccdadcf000)
libc.so.6 => /lib64/libc.so.6 (0x00007fccdaa0c000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fccda808000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fccda5ec000)
librt.so.1 => /lib64/librt.so.1 (0x00007fccda3e3000)
libX11.so.6 => /lib64/libX11.so.6 (0x00007fccda0a3000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fccd9d1c000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fccd9b04000)
libGLX.so.0 => /lib64/libGLX.so.0 (0x00007fccd98d4000)
libGLdispatch.so.0 => /lib64/libGLdispatch.so.0 (0x00007fccd95eb000)
/lib64/ld-linux-x86-64.so.2 (0x000055a76893d000)
libxcb.so.1 => /lib64/libxcb.so.1 (0x00007fccd93c8000)
libXext.so.6 => /lib64/libXext.so.6 (0x00007fccd91b6000)
libXau.so.6 => /lib64/libXau.so.6 (0x00007fccd8fb1000)
As you can see it links against libstdc++, so I guess another lib need it. How can I check what call is requesting this lib or get more information about the issue?
Thanks.

Run your application as LD_DEBUG=all <cmd-line>, e.g.:
LD_DEBUG=all kwin --version |& grep "needed by"
Outputs:
...
17448: file=libc.so.6 [0]; needed by kwin [0]
17448: file=libxcb-image.so.0 [0]; needed by /lib64/libkwin4_effect_builtins.so.1 [0]
...

Related

Mesa glGetString() version differs from glxinfo

In my application I have this piece of code
void showOpenGLInfo()
{
printf("Graphic card vendor: %s\n", glGetString(GL_VENDOR));
printf("Renderer: %s\n", glGetString(GL_RENDERER));
printf("GL version: %s\n", glGetString(GL_VERSION));
printf("GLSL version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
}
that shows this output on the application log:
Graphic card vendor: Intel
Renderer: Mesa Intel(R) UHD Graphics 600 (GLK 2)
GL version: 4.6 (Compatibility Profile) Mesa 20.3.5
GLSL version: 4.60
I have build Mesa driver 22.0.1 version from source code and glxinfo reports the correct value:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 22.0.1
I don't understand this difference, any tip? Debian 11 Bullseye.
Add some OpenGL information:
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) UHD Graphics 600 (GLK 2)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 22.0.1
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 22.0.1
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 22.0.1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
Add other information based on comments:
ldd /usr/bin/glxinfo
linux-vdso.so.1 (0x00007ffc9c5f6000)
libGLEW.so.2.1 => /lib/x86_64-linux-gnu/libGLEW.so.2.1 (0x00007f3b2a68f000)
libGLU.so.1 => /lib/x86_64-linux-gnu/libGLU.so.1 (0x00007f3b2a61f000)
libGL.so.1 => /lib/x86_64-linux-gnu/libGL.so.1 (0x00007f3b2a598000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3b2a454000)
libX11.so.6 => /lib/x86_64-linux-gnu/libX11.so.6 (0x00007f3b2a311000)
libXext.so.6 => /lib/x86_64-linux-gnu/libXext.so.6 (0x00007f3b2a2fc000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3b2a135000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3b29f68000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3b29f4e000)
libGLdispatch.so.0 => /lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f3b29e96000)
libGLX.so.0 => /lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f3b29e62000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3b2a760000)
libxcb.so.1 => /lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f3b29e37000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3b29e2f000)
libXau.so.6 => /lib/x86_64-linux-gnu/libXau.so.6 (0x00007f3b29e2a000)
libXdmcp.so.6 => /lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f3b29c24000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f3b29c0d000)
libmd.so.0 => /lib/x86_64-linux-gnu/libmd.so.0 (0x00007f3b29c00000)
ldd my_application
linux-vdso.so.1 (0x00007ffe0092c000)
libc.so.6 => /lib/x86-64-linux-gnu/libc.so.6 (0x00007f1f23936000)
libz.so.1 => /lib/x86-64-linux-gnu/libz.so.1 (0x00007f1f2391a000)
libSDL2-2.0.so.0 => /lib/x86-64-linux-gnu/libSDL2-2.0.so.0 (0x00007f1f237c5000)
libSDL2_image-2.0.so.0 => /lib/x86-64-linux-gnu/libSDL2_image-2.0.so.0 (0x00007f1f237a2000)
libdl.so.2 => /lib/x86-64-linux-gnu/libdl.so.2 (0x00007f1f2379c000)
libm.so.6 => /lib/x86-64-linux-gnu/libm.so.6 (0x00007f1f2364d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1f23b4e000)
libasound.so.2 => /lib/x86-64-linux-gnu/libasound.so.2 (0x00007f1f23550000)
libpulse.so.0 => /lib/x86-64-linux-gnu/libpulse.so.0 (0x00007f1f234fb000)
libX11.so.6 => /lib/x86-64-linux-gnu/libX11.so.6 (0x00007f1f233be000)
libXext.so.6 => /lib/x86-64-linux-gnu/libXext.so.6 (0x00007f1f233a9000)
libXcursor.so.1 => /lib/x86-64-linux-gnu/libXcursor.so.1 (0x00007f1f2339c000)
libXinerama.so.1 => /lib/x86-64-linux-gnu/libXinerama.so.1 (0x00007f1f23397000)
libXi.so.6 => /lib/x86-64-linux-gnu/libXi.so.6 (0x00007f1f23383000)
libXrandr.so.2 => /lib/x86-64-linux-gnu/libXrandr.so.2 (0x00007f1f23376000)
libXss.so.1 => /lib/x86-64-linux-gnu/libXss.so.1 (0x00007f1f23371000)
libXxf86vm.so.1 => /lib/x86-64-linux-gnu/libXxf86vm.so.1 (0x00007f1f2336a000)
libwayland-egl.so.1 => /lib/x86-64-linux-gnu/libwayland-egl.so.1 (0x00007f1f23365000)
libwayland-client.so.0 => /lib/x86-64-linux-gnu/libwayland-client.so.0 (0x00007f1f23354000)
libwayland-cursor.so.0 => /lib/x86-64-linux-gnu/libwayland-cursor.so.0 (0x00007f1f23347000)
libxkbcommon.so.0 => /lib/x86-64-linux-gnu/libxkbcommon.so.0 (0x00007f1f23305000)
libpthread.so.0 => /lib/x86-64-linux-gnu/libpthread.so.0 (0x00007f1f232e2000)
libpng16.so.16 => /lib/x86-64-linux-gnu/libpng16.so.16 (0x00007f1f232aa000)
libjpeg.so.8 => /lib/x86-64-linux-gnu/libjpeg.so.8 (0x00007f1f23225000)
libtiff.so.5 => /lib/x86-64-linux-gnu/libtiff.so.5 (0x00007f1f231a4000)
libwebp.so.6 => /lib/x86-64-linux-gnu/libwebp.so.6 (0x00007f1f23138000)
libpulsecommon-13.99.so => /usr/lib/x86-64-linux-gnu/pulseaudio/libpulsecommon-13.99.so (0x00007f1f230b6000)
libdbus-1.so.3 => /lib/x86-64-linux-gnu/libdbus-1.so.3 (0x00007f1f23065000)
libxcb.so.1 => /lib/x86-64-linux-gnu/libxcb.so.1 (0x00007f1f2303b000)
libXrender.so.1 => /lib/x86-64-linux-gnu/libXrender.so.1 (0x00007f1f22e31000)
libXfixes.so.3 => /lib/x86-64-linux-gnu/libXfixes.so.3 (0x00007f1f22e27000)
libffi.so.7 => /lib/x86-64-linux-gnu/libffi.so.7 (0x00007f1f22e1b000)
libzstd.so.1 => /lib/x86-64-linux-gnu/libzstd.so.1 (0x00007f1f22d72000)
liblzma.so.5 => /lib/x86-64-linux-gnu/liblzma.so.5 (0x00007f1f22d49000)
libjbig.so.0 => /lib/x86-64-linux-gnu/libjbig.so.0 (0x00007f1f22b3b000)
libsystemd.so.0 => /lib/x86-64-linux-gnu/libsystemd.so.0 (0x00007f1f22a8a000)
libwrap.so.0 => /lib/x86-64-linux-gnu/libwrap.so.0 (0x00007f1f22a7e000)
libsndfile.so.1 => /lib/x86-64-linux-gnu/libsndfile.so.1 (0x00007f1f22a00000)
libasyncns.so.0 => /lib/x86-64-linux-gnu/libasyncns.so.0 (0x00007f1f227fa000)
libapparmor.so.1 => /lib/x86-64-linux-gnu/libapparmor.so.1 (0x00007f1f227e5000)
librt.so.1 => /lib/x86-64-linux-gnu/librt.so.1 (0x00007f1f227db000)
libXau.so.6 => /lib/x86-64-linux-gnu/libXau.so.6 (0x00007f1f227d3000)
libXdmcp.so.6 => /lib/x86-64-linux-gnu/libXdmcp.so.6 (0x00007f1f227cb000)
liblz4.so.1 => /lib/x86-64-linux-gnu/liblz4.so.1 (0x00007f1f227aa000)
libgcrypt.so.20 => /lib/x86-64-linux-gnu/libgcrypt.so.20 (0x00007f1f2268c000)
libnsl.so.1 => /lib/x86-64-linux-gnu/libnsl.so.1 (0x00007f1f2266f000)
libFLAC.so.8 => /lib/x86-64-linux-gnu/libFLAC.so.8 (0x00007f1f2262f000)
libogg.so.0 => /lib/x86-64-linux-gnu/libogg.so.0 (0x00007f1f22622000)
libvorbis.so.0 => /lib/x86-64-linux-gnu/libvorbis.so.0 (0x00007f1f225f4000)
libvorbisenc.so.2 => /lib/x86-64-linux-gnu/libvorbisenc.so.2 (0x00007f1f22549000)
libresolv.so.2 => /lib/x86-64-linux-gnu/libresolv.so.2 (0x00007f1f2252d000)
libbsd.so.0 => /lib/x86-64-linux-gnu/libbsd.so.0 (0x00007f1f22513000)
libgpg-error.so.0 => /lib/x86-64-linux-gnu/libgpg-error.so.0 (0x00007f1f224ee000)
I found the mistake. My app points to /lib/x86-64-linux-gnu instead of /lib/x86_64-linux-gnu. Now I can use Mesa 22.01 built from source. Many thanks to #genpfault and #derhass for their help

How can I access an Array within a Hash? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am building an installer for perl modules we require at work. After all of the dependencies are installed, I need to check if the module is working properly "use This::Module". The problem is, all of the modules are being installed within a certain order.
The hash looks like...
my %modules=(
0 => {'name' => '/root/mods/CGI/perl-FCGI-0.74-8.amzn2.0.2.x86_64.rpm', 'method' => 'rpm', 'status'=>'pending'},
1 => {'name' => '/root/mods/CGI/perl-CGI-3.63-4.amzn2.noarch.rpm', 'method' => 'rpm','status'=>'done', 'validate' => ['CGI','CGI::Carp']},
2 => {'name' => '/root/mods/Digest/perl-Digest-1.17-245.amzn2.noarch.rpm', 'method' => 'rpm','status'=>'pending'},
3 => {'name' => '/root/mods/Digest/perl-Digest-MD5-2.52-3.amzn2.0.2.x86_64.rpm', 'method' => 'rpm','status'=>'done', 'validate' => ['Digest::MD5']},
4 => {'name' => '/root/mods/HTTP/perl-Business-ISBN-Data-20120719.001-2.el7.noarch.rpm','method' => 'rpm','status'=>'pending'},
5 => {'name' => '/root/mods/HTTP/perl-Data-Dumper-2.145-3.el7.x86_64.rpm','method' => 'rpm','status'=>'pending'},
6 => {'name' => '/root/mods/HTTP/perl-Business-ISBN-2.06-2.el7.noarch.rpm','method' => 'rpm','status'=>'done'}, 'validate' => ['HTTP::Request::Common']},
Each newline is the start of a new module. Once one the 'status' => 'done' I need to access the modules within 'validate'. This is an array because there are cases where there are multiple modules tied to one install sequence.
How can I loop through and return each array element by itself?
'validate' => {['CGI','CGI::Carp']}},
You don't have arrays.
The value of validate is between { and } so it is a hashref.
The arrayref is the first entry in the hash, so it gets converted to a string to be used as a key.
You end up with something like:
{
'name' => '/root/mods/CGI/perl-CGI-3.63-4.amzn2.noarch.rpm',
'method' => 'rpm',
'status' => 'done',
'validate' => {
'ARRAY(0x7f9ab601c4e0)' => undef
}
};
Make sure you use strict; and use warnings;. It would have alerted you to this:
Odd number of elements in anonymous hash at Untitled.pl line 9.
You need to fix your data structure. If you want an array, then put it in an array.
#!/usr/bin/perl
use strict;
use warnings;
use v5.10;
use Data::Dumper;
my %modules = (
0 => {
'name' => '/root/mods/CGI/perl-FCGI-0.74-8.amzn2.0.2.x86_64.rpm',
'method' => 'rpm',
'status' => 'pending'
},
1 => {
'name' => '/root/mods/CGI/perl-CGI-3.63-4.amzn2.noarch.rpm',
'method' => 'rpm',
'status' => 'done',
'validate' => [ 'CGI', 'CGI::Carp' ]
},
);
Then you can access the arrayref:
my $arrayref = $modules{1}->{validate};
and loop over it:
foreach my $value (#$arrayref) {
say $value
}

What about problems with loading native library/missing methods: libttJdbc.so, libtten.so

java.sql.SQLException: Problems with loading native library/missing methods: /home/timesten/TimesTen/tt1122/lib/libttJdbc.so: libtten.so: cannot open shared object file: No such file or directory
at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1794)
at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:305)
at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:161)
at java.sql.DriverManager.getConnection(DriverManager.java:620)
at java.sql.DriverManager.getConnection(DriverManager.java:222)
at Test.main(Test.java:15)
Thankyou
Code Example:
try{
String driverName = "com.timesten.jdbc.TimesTenClientDriver"; // "sun.jdbc.odbc.JdbcOdbcDriver"
String Url = "jdbc:timesten:client:dsn=timestendb_1122"; //"jdbc:odbc:timestendb_1122";
if(args.length >= 2){
driverName = args[0];
Url = args[1];
}
System.out.println("driverName=" + driverName);
System.out.println("Url=" + Url);
System.out.println("classPath=" + System.getProperty("java.library.path"));
Class.forName(driverName).newInstance();
// Open a connection to TimesTen
Connection conn = DriverManager.getConnection(Url);
if(conn != null){
System.out.println("okay");
}
else{
System.out.println("fail");
}
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
odbc.ini config:
[ODBC Data Sources]
timestendb_11221=TimesTen 11.2.2 Driver
[timestendb_1122]
TTC_SERVER=(Host || IP)
UID=Username
PWD=Password
TTC_SERVER_DSN=Cachedb01
Error: java.sql.SQLException: Problems with loading native
library/missing methods: /opt/TimesTen/tt1122/lib/libttJdbcCS.so:
libttclient.so: cannot open shared object file: No such file or
directory
Resolve:
Check if exists:
$ldd /opt/TimesTen/tt1122/lib/libttJdbcCS.so
Screen:
linux-vdso.so.1 => (0x00007fff039b4000)
libttclient.so => not found
libttco.so => not found
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f57d642e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f57d6218000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57d5e58000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57d5c53000)
/lib64/ld-linux-x86-64.so.2 (0x00007f57d6876000)
Check directory timesten client: $ ll /opt/TimesTen/tt1122/lib/libttclient.so
Go to to file to add share lib : sudo vi /etc/ld.so.conf.d/extension.conf -> Add: /opt/TimesTen/tt1122/lib
Check Again
java -Djava.library.path=/opt/TimesTen/tt1122/lib -jar test1.jar
Code Print:
driverName=com.timesten.jdbc.TimesTenClientDriver
Url=jdbc:timesten:client:dsn=timestendb_1122
classPath=/opt/TimesTen/tt1122/lib
java.sql.SQLException: [TimesTen][TimesTen 11.2.2.5.0 CLIENT]Cannot find the requested DSN (timestendb_1122) in ODBCINI, Unable to open /var/TimesTen/tt1122/sys.odbc.ini. Permission denied
Resolve:
export ODBCINI=/etc/odbc.ini (if you used odbc driver)
export ODBCINI=/var/TimesTen/tt1122/sys.odbc.ini (if used timesten driver)
Can be add bash file for user:
nano /home/nhatvd/.bashrc
export ODBCINI=/etc/odbc.ini
$ ldd /opt/TimesTen/tt1122/lib/libttJdbcCS.so
linux-vdso.so.1 => (0x00007fff429fe000)
libttclient.so => /opt/TimesTen/tt1122/lib/libttclient.so (0x00007fd7977ee000)
libttco.so => /opt/TimesTen/tt1122/lib/libttco.so (0x00007fd797520000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd797223000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd79700d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd796c4d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd796a48000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd796748000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd79652b000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007fd796310000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd797b12000)
Result:
$ java -Djava.library.path=/opt/TimesTen/tt1122/lib -jar test1.jar
Code Print:
driverName=com.timesten.jdbc.TimesTenClientDriver
Url=jdbc:timesten:client:dsn=timestendb_1122
classPath=/opt/TimesTen/tt1122/lib
okay
DONE.

dtrace libc probes on opensolaris

when im trying to do trace getenv function i got:
-bash-4.0#/usr/sbin/dtrace -n 'pid$target:libc:getenv:entry' -p 2017
dtrace: invalid probe specifier pid$target:libc:getenv:entry: probe description
pid2017:libc:getenv:entry does not match any probes
-bash-4.0# /usr/sbin/dtrace -n 'pid$target:libc::entry' -p 2017
dtrace: invalid probe specifier pid$target:libc::entry: probe description pid2017:libc::entry does not match any probes
ldd from myapp:
libz.so.1 => /lib/libz.so.1
libm.so.2 => /lib/libm.so.2
libdl.so.1 => /lib/libdl.so.1
libpthread.so.1 => /lib/libpthread.so.1
libbz2.so.1 => /usr/lib/libbz2.so.1
libsocket.so.1 => /lib/libsocket.so.1
libnsl.so.1 => /lib/libnsl.so.1
libsendfile.so.1 => /lib/libsendfile.so.1
libxml2.so.2 => /lib/libxml2.so.2
libc.so.1 => /lib/libc.so.1
libmp.so.2 => /lib/libmp.so.2
libmd.so.1 => /lib/libmd.so.1
libscf.so.1 => /lib/libscf.so.1
libuutil.so.1 => /lib/libuutil.so.1
libgen.so.1 => /lib/libgen.so.1
libsmbios.so.1 => /usr/lib/libsmbios.so.1
Why is that happening ? Is there any solution which can make libc functions able to trace via dtrace ?
Best regards

Retaining parent slugs in CakePHP

I'm experimenting with SEO friendly URL's in CakePHP as efficiently as I can, I've managed to use the current format, each example uses function view($slug) except for the first example which uses function index().
/categories/
/categories/books/
/categories/books/it-and-computing/
But what if IT & Computing has a sub-category "Web Development"? I'd like the URL to become:
/categories/books/it-and-computing/web-development/
I'm not sure how to do this without creating too many routes. Here is my route code so far:
Router::connect('/categories/', array('controller' => 'categories', 'action' => 'index'));
Router::connect('/categories/:slug',
array('controller' => 'categories', 'action' => 'view'),
array('pass' => array('slug'))
);
Router::connect('/categories/:parent/:slug',
array('controller' => 'categories', 'action' => 'view'),
array('pass' => array('parent', 'slug'))
);
Any help would be greatly appreciated
Kind Regards
Stephen
// in routes.php
Router::connect('/categories/:row:lastslash',array('controller' => 'settings', 'action' => 'show',),array(
'pass'=>array('row'),
'row'=>'.*?',
'lastslash'=>'\/?'
));
//in controller
function show($row = ""){
if($row){
$categories = split('/',$row);
?><pre><? print_r($categories);?></pre><?die();
}else{
die('do something else');
}
}
/categories/books/computing/web-development/cakephp/
result:
Array
(
[0] => books
[1] => computing
[2] => web-development
[3] => cakephp
)
/categories/
result:
do something else
/categories/books
result:
Array
(
[0] => books
)

Resources