Run Mongoose server

196 views
Skip to first unread message

Jijo Thomas

unread,
Jun 23, 2014, 4:15:45 AM6/23/14
to mongoos...@googlegroups.com
I am new in Mongoose server. My doubt is how to run mongoose server in my mac. I want to run it from terminal. i am trying to load hello.c in the example project that you have given with gcc compiler, but fail to run. Please find the error that i get when i run "gcc hello.c" in terminal. Please help me

Undefined symbols for architecture x86_64:
  "_mg_add_uri_handler", referenced from:
      _main in hello-e35d38.o
  "_mg_create_server", referenced from:
      _main in hello-e35d38.o
  "_mg_get_option", referenced from:
      _main in hello-e35d38.o
  "_mg_poll_server", referenced from:
      _main in hello-e35d38.o
  "_mg_printf_data", referenced from:
      _index_html in hello-e35d38.o
  "_mg_set_option", referenced from:
      _main in hello-e35d38.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Sergey Lyubka

unread,
Jun 23, 2014, 4:33:46 AM6/23/14
to mongoose-users
You need to add mongoose.c to the compilation


--
You received this message because you are subscribed to the Google Groups "mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongoose-user...@googlegroups.com.
To post to this group, send email to mongoos...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/d/optout.

Jijo Thomas

unread,
Jun 23, 2014, 6:26:24 AM6/23/14
to mongoos...@googlegroups.com
Yes,  already added Mongoose.c file and mongoose.h file. Both the files and hello.c are in the same folder.

Sergey Lyubka

unread,
Jun 23, 2014, 6:32:18 AM6/23/14
to mongoose-users

Make sure mongoose.c and hello.c are from the same repo revision

Jijo Thomas

unread,
Jun 23, 2014, 6:37:30 AM6/23/14
to mongoos...@googlegroups.com
Yes, i am trying to run mongoose server in my local machine. i want to load the server without .dmg file. Thats why i use terminal. I placed mongoose.h, mongoose.c and hello.c in the same folder. Now i am trying to load the server, but fails. i don't know how to solve this. Please help me.

jeff shanab

unread,
Jun 23, 2014, 6:40:52 AM6/23/14
to mongoos...@googlegroups.com
Could this possibly be an issue with building fat binaries? ie you
have it set to compile 32 but link for both. Usually this would be
very rare, but I don't know your environment.

Sergey Lyubka

unread,
Jun 23, 2014, 6:49:21 AM6/23/14
to mongoose-users

To build command line binary on Mac, clone the repo then
cd  mongoose/examples
make server

Jijo Thomas

unread,
Jun 23, 2014, 6:56:09 AM6/23/14
to mongoos...@googlegroups.com
Ok, can i run the files locally? Because i download all files from git. So i think i don't need to clone with the repository. First time i tired to compile using gcc compiler it shows error for mongoose.c file. Now i fixed it by copying mongoose.c and mongoose.h to examples folder. then in terminal i tried to compile from examples folder its shows the above error. Can you please explain in detail. Please...

Sergey Lyubka

unread,
Jun 23, 2014, 6:59:52 AM6/23/14
to mongoose-users

You were told exactly what to do to compile the example. Yet you don't think you need to do that and still asking for help. What kind of answer do you expect?

Jijo Thomas

unread,
Jun 23, 2014, 7:05:45 AM6/23/14
to mongoos...@googlegroups.com
Sorry Sergey.. i tried as you said, but i got this as response, i don't know i to resolve this, thats why i am asking for help again and again.

Mac-MacBook-Pro: examples myMac $ gcc hello.c
Undefined symbols for architecture x86_64:
  "_mg_add_uri_handler", referenced from:
      _main in hello-f08c15.o
  "_mg_create_server", referenced from:
      _main in hello-f08c15.o
  "_mg_get_option", referenced from:
      _main in hello-f08c15.o
  "_mg_poll_server", referenced from:
      _main in hello-f08c15.o
  "_mg_printf_data", referenced from:
      _index_html in hello-f08c15.o
  "_mg_set_option", referenced from:
      _main in hello-f08c15.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

jeff shanab

unread,
Jun 23, 2014, 7:12:45 AM6/23/14
to mongoos...@googlegroups.com
I have a MAC handy so I just cloned, cd and ran make. No problem.

paiste:examples jeffshanab$ make server
g++ server.c ../mongoose.c -o server -W -Wall -I.. -pthread -g -pipe
-lssl -g -O0
clang: warning: treating 'c' input as 'c++' when in C++ mode, this
behavior is deprecated
clang: warning: treating 'c' input as 'c++' when in C++ mode, this
behavior is deprecated
paiste:examples jeffshanab$

Jijo Thomas

unread,
Jun 23, 2014, 7:25:18 AM6/23/14
to mongoos...@googlegroups.com
Thanks jshanab. Now i can start the server as you said, problem is with server.c file. Is it is possible to open the port in 8080 as normal like dmg installation? Is it is possible to open a browser with default 8080 port and load the c file inside browser (if c file has some embedded html code).

jeff shanab

unread,
Jun 23, 2014, 7:29:02 AM6/23/14
to mongoos...@googlegroups.com
"Ok, can i run the files locally? Because i download all files from
git. So i think i don't need to clone with the repository."

This sentence just made me say HUH?
can I run the files locally? yes, of course what else is there?
"Download all file from git" IS clone. some sites will let you
download the repo as a tar file but it is the same result
You clone from a repo not with. small emantic but it pulls the info
down and includes a file that would let you commit changes IF you had
permission and easily get updates. So in this case clone it is purely
a download feature

Jijo Thomas

unread,
Jun 23, 2014, 7:36:09 AM6/23/14
to mongoos...@googlegroups.com
 OK jshanab, i understand what you said. Now i need to run a c file. is it is possible to open the browser in default port if that c contain some HTML content. I did it in windows, but in mac nothing happens.

jeff shanab

unread,
Jun 23, 2014, 7:37:46 AM6/23/14
to mongoos...@googlegroups.com
another painful question. I think we are suffering a bit of language
barrier. The server can be started to listen on multiple ports. I
have dealt mostly with embedding so I will let sergy jump in on that
but if you just read a bit of the code you should see the command line
options. So if you look at hello.c you can easily see the line that
sets the port to 8080

Browsers load html pages from servers like mongoose.
You would add a port to the URL like http://localhost:8080

Do you mean load the C file as text? C is source code it CANNOT
opererate without being compiled into object code which is not human
readable.

Jijo Thomas

unread,
Jun 23, 2014, 7:48:34 AM6/23/14
to mongoos...@googlegroups.com
Right jshanab, language problem is little bit there. In windows i wrote a .c file, when i run that .c files it opens the browser in URL http://localhost:8080  and display the html page that i wrote inside the .c file. I want the same in Mac also. Here i run the "make hello" an exec file is created inside the folder. But nothing happens. Is it is possible in mac ?

jeff shanab

unread,
Jun 23, 2014, 8:00:28 AM6/23/14
to mongoos...@googlegroups.com
Hey, you are already a step ahead of me, you know more than one
language (on the human side)

There are 3 separate things here.

files with .c must me compiled to run.
browsers are different depending on who wrote them and only display HTML pages
HTML pages MUST start with <html>
and end with </html>

If I am understanding you correctly you are writing a C program that
writes out a HTML file and then calls the browser for you.???

So you will have something like this

File* fp
fp open ("mypage.html","w")

fprintf(fp, "<HTML>\n")
fprintf .....
...
fprintf(fp, "</HTML>\n"

system("firefox mypage.html")

Jijo Thomas

unread,
Jun 23, 2014, 8:20:21 AM6/23/14
to mongoos...@googlegroups.com
Yes jshanab, i know three languages (human side). 
Yes, i wrote HTML as you said. My main concern is how to run this hello.c file. 
In terminal i wrote make hello.c, it creates an executable file. 
then what is the next step?? How to run that hello file. I used some printf inside that c file. Nothings shows in the terminal.
Nothings happens... 
What is the command for run the hello.c file and start the mongoose server in a specified port??

jeff shanab

unread,
Jun 23, 2014, 8:22:44 AM6/23/14
to mongoos...@googlegroups.com
./hello

(You need the ./ since this directory is not actually in your path.)

Jijo Thomas

unread,
Jun 23, 2014, 8:25:45 AM6/23/14
to mongoos...@googlegroups.com
Mac-MacBook-Pro:examples myMac$ make hello
make: `hello' is up to date.
Mac-MacBook-Pro:examples myMac$ hello
-bash: hello: command not found

:(

jeff shanab

unread,
Jun 23, 2014, 9:17:43 AM6/23/14
to mongoos...@googlegroups.com
"dot slash"

./hello

Gotta tell the system the directory the file is in. Either directly

~/mongoose/examples/hello
./hello
or add your directory to the path

Jijo Thomas

unread,
Jun 23, 2014, 9:47:47 AM6/23/14
to mongoos...@googlegroups.com
Great... Thanks... Great help jshanab.. Thanks a lot. Now i can start the server in port 8080. This is what i really want. 
Reply all
Reply to author
Forward
0 new messages