Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6124903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:11:10+00:00 2026-05-23T16:11:10+00:00

I have a simple C++ program: #include <iostream> int main() { std::cout << "Hello\n";

  • 0

I have a simple C++ program:

#include <iostream>

int main()
{
        std::cout << "Hello\n";
        return 0;
}

I was playing with "scratchbox" – cross compilation platform that I use in order to compile applications for ARM platform. I run it on my Nokia N900 phone.

While investigating some performance problems I noticed several calls to strcmp() in the beginning. I used "ltrace" to trace the library calls and when I run it on a target (my cell phone) a see series of calls to strcmp() which is now making me curious – what is the purpose of these calls?

20:06 user@MaemoBox:~$ ltrace test
__libc_start_main(61732, 1, 0xbed66634, 345616, 345612 <unfinished ...>
__errno_location()                                                                                 = 0x4001d3b0
strrchr("test", '/')                                                                               = NULL
getuid()                                                                                           = 29999
bsearch("test", 0x00055966, 146, 1, 0x0000ed38 <unfinished ...>
strcmp("test", "mv")                                                                               = 7
strcmp("test", "sort")                                                                             = 1
strcmp("test", "tr")                                                                               = -13
strcmp("test", "sysctl")                                                                           = 1
strcmp("test", "test")                                                                             = 0
<... bsearch resumed> )                                                                            = 0x000559e2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:11:11+00:00Added an answer on May 23, 2026 at 4:11 pm

    Not sure, but could it be that test actually is the system test command, and not the program you wrote? This could happen for example if $PATH does not contain ., the current directory. And given that it is a small platform, all test, mv, etc., might actually be just one executable, which emulates the correct program by figuring out what it is called as? See Busybox for example.

    If that is the case, all the strcmp() are basically the executable trying to figure out what it is being run as. Solution: name your program something other than test, or run ltrace <path_to_your_executable>/test.

    The strrchr() call before the strcmp() calls suggests strongly that it is trying to extract the executable “basename”, without the directory. In which case, running it as "./test" won’t probably help, so you should rename it to something that’s unique. (Just a guess, again.)

    I could be wrong, since there is theoretically, the platform can do anything when it runs an executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple Hello World C++ program (main.cpp): #include <iostream> using namespace std; int
I have this simple c++ program #include <cstdlib> #include <iostream> #include <math.h> #include <stdlib.h>
I have a very simple test program, running on Solaris 5.8: #include <stdio.h> #include
I found this sample code on the msdn library #include <iostream> int main() {
I have a sample program in a file called helloworld.cpp: #include <iostream> using namespace
Say I have simple program that emulates a board game with a number of
I have a simple program that creates a thread, loops twenty times and then
I have a simple program to check if a port is open, but I
I have a simple python program that I'd like to daemonize. Since the point
I have a simple forms program that I have been fighting with for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.