Linux - Will be the death of me

A place For General Chit Chat Etc
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Linux - Will be the death of me

Post by Tazzi »

Not having the greatest start to using linux recently.. although Im running it through a VM which I think is probably half the issue. My poor work bench is beginning the grow a hole as I slowly etch my frustrations into it with a screwdriver :lol:

Theres two things Iv needed to do:
1) Mount a SD card which is linux formatted to edit and change files
2) Compile C code to linux format to run off of linux server

Here I am thinking, going to have a relaxing weekend, playing with something new. But nooooooooo, everything I play with cant just go smoothly like show in tutorials! :comp:

First problem, SDCard mounting. The inbuilt card reader on my laptop doesnt show as a device in VMware.. meaning my Ubuntu install doesnt see a SDcard, I can get it to recognise it by adding another hdd device in vmware but I dont think its quite the same or worked correctly. Iv gone and bought a SDcard reader but still having same problems with an error message of "wrong fs type, bad option, bad super block, missing codepage or helper program , or other error".
Would rather not have to install linux natively onto a hdd to solve this.. unless anyone has had previous experience/solutions?

Second issue.. compiling C code. Fairly straight forward in what was require:
1) Install GCC libraries
2) Compile all C files to Objective files
3) use 'sudo make' (Make file is present) to put everything together and compile program
It compiles successfully, and I can use the application happily in the Ubuntu OS installed. But as soon as I put it onto the website (Running linux... apache 2.2.. I think??), Im unable to communicate with it. I verified my hoster (godaddy) does allow running linux applications in php using simple commands like exec_shell by making a few linux programs to execute and check for a response (like hello world)... but no go with the bigger application :roll:

This has lead me to wonder if the problem is that Iv compiled the application in a different linux OS, and some of the libraries/functions used are not present on the hosters system? Or, compiled app is using newer libraries not availablein the old linux OS run on the server?
The C code provided is designed to be compiled on any system so that it can be integrated onto the desired platform (linux, unix, windows ect), which then communicates with your application software via a standard API, looking at the coding, its using standard libraries.. so I dont see why there would be any problems... but.. not my case!

Suggestions.. comments.. thoughts?
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
Chuff
Posts: 267
Joined: Thu Dec 20, 2012 5:28 pm
Location: Melbourne

Re: Linux - Will be the death of me

Post by Chuff »

Hey Tazzi,

Rather than running Linux in a VM, which may be the reason your not seeing your SD card, have you tried a live session of Linux on your PC?

Just about all the big Linux distributions allow you to boot a live session of the OS from a CD/DVD/USB (I predominantly use Lnux Mint) and run it without installing anything to your HDD. This will give Linux direct access to all your PC hardware without having VM sit in the middle which is what your doing now.

Normally once you shutdown/reboot the PC all the changes you have made during your live Linux session will be lost but this can be circumvented by saving your sessions to a USB allowing your to run your next live session and retain the changes you have made in between. I've never saved live sessions but a quick Google will show you how.

Chuff
˙ʎɐqǝ ɟɟo pɹɐoqʎǝʞ ǝsǝuıɥɔ ɐ ƃuıʎnq ɹoɟ ʇɥƃıɹ ǝɯ sǝʌɹǝs
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: Linux - Will be the death of me

Post by Tazzi »

That sounds exactly like what I need to do.. right.. time to read up some more!!
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
antus
Site Admin
Posts: 8237
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Linux - Will be the death of me

Post by antus »

1) Ive never had a problem with any usb sdcard adapter in linux/vmware. It seems like you have a strange piece of hardware there as they are pretty generic. Do you have a USB one you can use with USB passthrough to linux?

2) Yes, it'll be different library versions between your compiled version and the server your running on. To work around this you can add a flag to staticly link the file so that it wont need any shared libraries. This will make the file larger as all code will be in it (and its bad for security patching, since it needs to be rebuilt should any library content require an update) but its also more portable as the linux binary api pretty much never changes so the executable will run everywhere for the forseeable future.

I dont know if this is the best doc, but it should get you started. https://stackoverflow.com/questions/657 ... statically
You should be able to do something like add -Bstatic to the gcc or ld flags in the makefile somewhere. Run ldd <executable> on the output before and after and the systems dynamic linker will tell you what libraries the binary requires and where it will find them on the current system. If you get it right you'll see something like this on your original executable on the ubuntu system:

Code: Select all

[user@ant bin]$ ldd bash
	linux-vdso.so.1 =>  (0x00007ffe9f361000)
	libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f7f6c6c6000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f7f6c4c2000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f7f6c0f4000)
	/lib64/ld-linux-x86-64.so.2 (0x0000560aaccfb000)
And something like this after it's statically linked (no external dependencies).

Code: Select all

[user@ant bin]$ ldd 7z
	not a dynamic executable
As an aside, if something wont run and it is a normal dynamic executable you can use ldd like this to see what library your missing and install it.
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: Linux - Will be the death of me

Post by Tazzi »

1) I blame officeworks. Or maybe my luck? Or both? Always get the weird ass converters/hubs which don't play nicely.

2) Yeeeeeeeeeeeeeeeeeeeesssssssss. Ok.. this is what I wanna hear!! Right.. time to make everything static. Size of the file wont be a problem.. so long as its all together.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: Linux - Will be the death of me

Post by Tazzi »

When you get to that point where you just want to squeeze the issue so hard it just smashes....

Card reader doesnt like playing with vmware happily... doesnt 'disengage' from the host computer properly... *Sigh*.
Even on the odd occasion where it does want to connect, ubuntu terminal does not display the sdcard with doing sudo fdisk -l

So... time for the 8Gb usb and linux install...
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: Linux - Will be the death of me

Post by Tazzi »

Problem 2, made progress with compiling as a static application which worked like you put there Antus, and now shows 'not a dynamic executable'. Still runs happily on the vm image.
When running it on the server, it responds back with an error code of 6. Thats all.. just 6.

As far as I understand, this value is actually generated by the program itself. Whats ridiculous, is there is quite literally no 'return 6' in the entire application. *sigh*.
There must still be something different or not quite right.

Another suggestion I was given, was to compile the app on windows (or linux) on a separate computer, and run a socket connection between the server and laptop. Its a (major) fuck around but should get the job done... so long as I dont turn off the laptop... :lol:
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
User avatar
oldn64
Posts: 256
Joined: Mon May 28, 2018 5:05 pm
cars: Vq Statesman, VE SS wagon, VE Sv6, VY SV8, VL Belina
Location: Country Victoria on a direct road to WINTON

Re: Linux - Will be the death of me

Post by oldn64 »

Hello Tazzi,

I might be missing something here, but what are you trying to achieve? Application compiled and working on linux?

I do not like compiling linux stuff in windows. there are too many pitfalls. You would be far better to resolve the issues in linux. The big issue I have seen before is when people have been using visual studio c they tend to forget that the structure of the language is slightly different when native to linux. Therefore the errors you sometimes get are based purely on the code not being formatted 100%.

Would love to help but without looking at the code it makes it a little harder to work through.

On your vm side.

The card convertor will be your issue. VM will see the card as a drive whihc technically is correct but then when it ports it to the system will take only the card not the reader thus screwing up the port. I suspect you are using workstation for this? What version? the new versions are pretty good but you would have a lot more success booting a live cd like Antus has stated and then using linux with the card reader native.

Cheers
oldn64
User avatar
antus
Site Admin
Posts: 8237
Joined: Sat Feb 28, 2009 8:34 pm
cars: TX Gemini 2L Twincam
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Contact:

Re: Linux - Will be the death of me

Post by antus »

Run it as root under strace. that'll show you the system calls and return codes, usually gets to the bottom of wierd issues like that. Eg heres what I get running grep successfully so that it just shows only its help page. You can see a lot of detail about whats going on between it and the system.

Code: Select all

[antus@ant bin]$ strace grep
execve("/usr/bin/grep", ["grep"], [/* 75 vars */]) = 0
brk(NULL)                               = 0x133f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb6a000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=159779, ...}) = 0
mmap(NULL, 159779, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9cbeb42000
close(3)                                = 0
open("/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=402384, ...}) = 0
mmap(NULL, 2494984, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9cbe6e8000
mprotect(0x7f9cbe748000, 2097152, PROT_NONE) = 0
mmap(0x7f9cbe948000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x60000) = 0x7f9cbe948000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P%\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2173512, ...}) = 0
mmap(NULL, 3981792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9cbe31b000
mprotect(0x7f9cbe4de000, 2093056, PROT_NONE) = 0
mmap(0x7f9cbe6dd000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c2000) = 0x7f9cbe6dd000
mmap(0x7f9cbe6e3000, 16864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f9cbe6e3000
close(3)                                = 0
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0m\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144792, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb41000
mmap(NULL, 2208904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f9cbe0ff000
mprotect(0x7f9cbe116000, 2093056, PROT_NONE) = 0
mmap(0x7f9cbe315000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f9cbe315000
mmap(0x7f9cbe317000, 13448, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f9cbe317000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb3f000
arch_prctl(ARCH_SET_FS, 0x7f9cbeb3f740) = 0
mprotect(0x7f9cbe6dd000, 16384, PROT_READ) = 0
mprotect(0x7f9cbe315000, 4096, PROT_READ) = 0
mprotect(0x7f9cbe948000, 4096, PROT_READ) = 0
mprotect(0x624000, 4096, PROT_READ)     = 0
mprotect(0x7f9cbeb6b000, 4096, PROT_READ) = 0
munmap(0x7f9cbeb42000, 159779)          = 0
set_tid_address(0x7f9cbeb3fa10)         = 29987
set_robust_list(0x7f9cbeb3fa20, 24)     = 0
rt_sigaction(SIGRTMIN, {0x7f9cbe1057e0, [], SA_RESTORER|SA_SIGINFO, 0x7f9cbe10e6d0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7f9cbe105870, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7f9cbe10e6d0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL)                               = 0x133f000
brk(0x1360000)                          = 0x1360000
brk(NULL)                               = 0x1360000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0
mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9cb7bd6000
close(3)                                = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 9), ...}) = 0
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2502, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9cbeb69000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2502
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f9cbeb69000, 4096)            = 0
open("/usr/share/locale/en_AU.utf8/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_AU/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/grep.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "Usage: grep [OPTION]... PATTERN "..., 42Usage: grep [OPTION]... PATTERN [FILE]...
) = 42
write(2, "Try 'grep --help' for more infor"..., 40Try 'grep --help' for more information.
) = 40
close(1)                                = 0
close(2)                                = 0
exit_group(2)                           = ?
+++ exited with 2 +++
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
Tazzi
Posts: 3422
Joined: Thu May 17, 2012 8:53 pm
cars: VE SS Ute
Location: WA
Contact:

Re: Linux - Will be the death of me

Post by Tazzi »

oldn64 wrote:Hello Tazzi,

I might be missing something here, but what are you trying to achieve? Application compiled and working on linux?

I do not like compiling linux stuff in windows. there are too many pitfalls. You would be far better to resolve the issues in linux. The big issue I have seen before is when people have been using visual studio c they tend to forget that the structure of the language is slightly different when native to linux. Therefore the errors you sometimes get are based purely on the code not being formatted 100%.

Would love to help but without looking at the code it makes it a little harder to work through.

On your vm side.

The card convertor will be your issue. VM will see the card as a drive whihc technically is correct but then when it ports it to the system will take only the card not the reader thus screwing up the port. I suspect you are using workstation for this? What version? the new versions are pretty good but you would have a lot more success booting a live cd like Antus has stated and then using linux with the card reader native.

Cheers
oldn64
The code being compiled is not of my own. Its developed by a third party which is used for software licensing.

The code itself does compile happily and even runs in my Ubuntu linux setup, so it is confirmed that it compiles and runs.

The problem is that the application will not run correctly on my Linux server hosting (Godaddy).

Thanks for that Antus, I will give that a crack today. Setting up a local server using WAMP, and will test that I can get it running with an offline version of my site before tinkering further with the live server.
Your Local Aussie Reverse Engineer
Contact for Software/Hardware development and Reverse Engineering
Site:https://www.envyouscustoms.com
Mob:+61406 140 726
Image
Post Reply