Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C source

69 views
Skip to first unread message

Pol Hallen

unread,
Jul 15, 2016, 5:40:13 AM7/15/16
to
Hi, all

I've this error:

fatal error: md5.h: No such file or directory
compilation terminated.

when I compiled a source C

gcc source.c

[...]
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "md5.h"
[...]

I've openssl-dev installed, but I don't understand how to audit this error..

any idea?

thanks for help!

Pol

to...@tuxteam.de

unread,
Jul 15, 2016, 6:00:04 AM7/15/16
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Jul 15, 2016 at 11:34:38AM +0200, Pol Hallen wrote:
> Hi, all
>
> I've this error:
>
> fatal error: md5.h: No such file or directory
> compilation terminated.
>
> when I compiled a source C
>
> gcc source.c
>
> [...]
> #include <string.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include "md5.h"
> [...]
>
> I've openssl-dev installed, but I don't understand how to audit this error..

Hmmm. I can't find a package named "openssl-dev" in Debian. What distro are
you using? How is the package called really?

As your includes are written above, the C compiler would look for a file
md5.h in the current compilation directory: most probably there isn't
one, since whatever package you installed will put it in a standard
system location, typically under /usr/include.

You can find that out by

find /usr/include -name md5.h

Let's assume you get:

/usr/include/openssl/md5.h

... then you'd have to tell your C compiler

#include <openssl/md5.h>

(there are many other ways to steer that, like the -I command line
option, but let's start with this).

regards

[1] https://packages.debian.org/search?keywords=openssl-dev&searchon=names&suite=all&section=all

- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAleIstkACgkQBcgs9XrR2kYo1wCcC/eqRU9M+YDQnsXggqC45FEr
9OwAnjHs8mX+vozUSpnB9upyjZb2TgqB
=+NJu
-----END PGP SIGNATURE-----

Reco

unread,
Jul 15, 2016, 6:00:07 AM7/15/16
to
Hi.

On Fri, Jul 15, 2016 at 11:34:38AM +0200, Pol Hallen wrote:
#include with encased in 'less' and 'more' characters instructs
preprocessor to search header files system-wide. A search path can be
modified with -L flag.

#include with quotes instructs preprocessor to search a header file in
the current directory.

So probably you meant to write this:

#include <md5.h>

Reco

Pol Hallen

unread,
Jul 15, 2016, 6:10:05 AM7/15/16
to
sorry, my mistake about the package (I use debian testing)

> find /usr/include -name md5.h

find /usr/include/ -name md5.h
/usr/include/openssl/md5.h
/usr/include/crypto++/md5.h

> #include <openssl/md5.h>

now I've many errors

thanks for help!

alice.c:50:18: error: unknown type name ‘md5_context’
void md5_starts( md5_context *ctx )
^
alice.c:61:19: error: unknown type name ‘md5_context’
void md5_process( md5_context *ctx, uint8 data[64] )
^
alice.c:61:37: error: unknown type name ‘uint8’
void md5_process( md5_context *ctx, uint8 data[64] )
^
alice.c:184:18: error: unknown type name ‘md5_context’
void md5_update( md5_context *ctx, uint8 *input, uint32 length )
^
alice.c:184:36: error: unknown type name ‘uint8’
void md5_update( md5_context *ctx, uint8 *input, uint32 length )
^
alice.c:184:50: error: unknown type name ‘uint32’
void md5_update( md5_context *ctx, uint8 *input, uint32 length )
^
alice.c:223:8: error: unknown type name ‘uint8’
static uint8 md5_padding[64] =
^
alice.c:231:18: error: unknown type name ‘md5_context’
void md5_finish( md5_context *ctx, uint8 digest[16] )
^
alice.c:231:36: error: unknown type name ‘uint8’
void md5_finish( md5_context *ctx, uint8 digest[16] )
^
alice.c: In function ‘main’:
alice.c:299:3: error: unknown type name ‘md5_context’
md5_context ctx;
^
alice.c:321:3: warning: implicit declaration of function ‘md5_starts’
[-Wimplicit-function-declaration]
md5_starts( &ctx );
^
alice.c:325:7: warning: implicit declaration of function ‘md5_update’
[-Wimplicit-function-declaration]
md5_update( &ctx, buf, i );
^
alice.c:332:3: warning: implicit declaration of function ‘md5_finish’
[-Wimplicit-function-declaration]
md5_finish( &ctx, md5sum );
^


Pol

Pol Hallen

unread,
Jul 15, 2016, 6:10:07 AM7/15/16
to
> #include <md5.h>

I've same problem :-/


--
Pol

Nicolas George

unread,
Jul 15, 2016, 6:20:05 AM7/15/16
to
L'octidi 28 messidor, an CCXXIV, Pol Hallen a écrit :
> #include <string.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include "md5.h"

The fact that md5.h is included with double quotes instead of angle brackets
means that it is a header local to the project, not a system header. Your .c
file should come with the md5.h file. If it does not, it is bogus.

The suggestions of adding -I options, finding a file on the system or
installing a package are wrong, but they may become correct once the first
issue is fixed.

The suggestion about -L is completely wrong, -L is about linking, not
compiling.

Regards,

--
Nicolas George
signature.asc

Thomas Schmitt

unread,
Jul 15, 2016, 6:20:05 AM7/15/16
to
Hi,

i second tomás' assessment and proposal.


Reco wrote:
> #include with encased in 'less' and 'more' characters instructs
> preprocessor to search header files system-wide. A search path can be
> modified with -L flag.

It is not a system-wide search, but rather a search iterating over a list
of directory prefixes:
https://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html

That's why i agree with tomás that e.g.
/usr/include/openssl/md5.h
should be used like

#include <openssl/md5.h>

because i expect that /usr/include is in the prefix list.

gcc -L is for libraries (-l):
https://gcc.gnu.org/onlinedocs/gcc-4.9.3/gcc/Directory-Options.html#Directory-Options
Own include directories are added by -I for
#include <...>
or -iquote for
$include "..."


> #include with quotes instructs preprocessor to search a header file in
> the current directory.

But if not found there, the prefix list is searched, too.


Have a nice day :)

Thomas

Jonathan Dowland

unread,
Jul 15, 2016, 6:30:04 AM7/15/16
to
On Fri, Jul 15, 2016 at 12:07:09PM +0200, Pol Hallen wrote:
> alice.c:50:18: error: unknown type name ‘md5_context’
> void md5_starts( md5_context *ctx )

These aren't typedefs used by openssl. It looks like your code
is designed to be used with a completely different md5.h.

FWIW, last time I wanted to do md5 in C, I copied the code into my own
project. I got it from the source to dpkg, which did the same thing.

https://github.com/chocolate-doom/chocolate-doom/commit/09180d3f73e522c1e0c43993aec28cf339dcf74d#diff-2fd6f21ae40fa979b9535d9f78ae4f0d

> alice.c:61:37: error: unknown type name ‘uint8’
> void md5_process( md5_context *ctx, uint8 data[64] )
> ^

This code must rely on some header or library defining a bunch of integer
types. uint8 is clearly meant to be an unsigned char. There's a standard
header <inttypes.h> that gives you uint8_t and friends, but not without
the _t suffix. inttypes.h is part of the ISO C99 standard and perhaps
others.

You need to find out what the actual dependencies of the code you are
trying to compile.

--
Jonathan Dowland
Please do not CC me, I am subscribed to the list.
signature.asc

Jens Sauer

unread,
Jul 15, 2016, 6:30:04 AM7/15/16
to

I think you are missing dependencies from the ssl library. Have a look into the docs [1].

Your questions implies that you are not very experienced in C coding.
Maybe you should ask yourself the question if starting with a complex and potential security risky api like openssl is the right thing for a beginner.

Happy coding

[1] https://www.openssl.org/docs/manmaster/ssl/ssl.html

Thomas Schmitt

unread,
Jul 15, 2016, 6:30:04 AM7/15/16
to
Hi,

Pol Hallen wrote:
> now I've many errors
> alice.c:50:18: error: unknown type name ‘md5_context’
> alice.c:61:37: error: unknown type name ‘uint8’

This might indicate that openssl/md5.h is not the md5.h which is needed
for your source code. If so, then <openssl/md5.h> was rather a red herring.
(One can be right and misleading at the same time.)

Your alice.c would want to see a companion file md5.h from its own family.
Probably you find it where you found alice.c.

Jonathan Dowland

unread,
Jul 15, 2016, 6:30:04 AM7/15/16
to
On Fri, Jul 15, 2016 at 12:23:01PM +0200, Jens Sauer wrote:
> I think you are missing dependencies from the ssl library. Have a look into
> the docs [1].

Doesn't look like openssl to me. Openssl just happens to also have a md5.h
header in it.
signature.asc

Nicolas George

unread,
Jul 15, 2016, 6:40:03 AM7/15/16
to
L'octidi 28 messidor, an CCXXIV, Jonathan Dowland a écrit :
> FWIW, last time I wanted to do md5 in C, I copied the code into my own
> project. I got it from the source to dpkg, which did the same thing.

By doing that, you are depriving yourself of future bugfixes and
improvements to that implementation. Well, MD5 is pretty much set in stone
and can be completely tested, so it is not a serious concern, but I wanted
to underline it for the record.

More importantly, by doing that, you are depriving yourself of all
optimizations that were introduced in more mature crypto libraries. Since
MD5 is computationally intensive, this is a serious concern. If your project
only does a few MD5 on small chunks of data while spending most of its time
in other tasks, then it is certainly fine. Otherwise, this is a very bad
idea. The difference is quite significant, sometimes more than 30% depending
on the hardware.

I have found that OpenSSL's implementation was the fastest amongst readily
available crypto implementations (gcrypt, libtomcrypt, libavutil).

Regards,

--
Nicolas George
signature.asc

Andre Majorel

unread,
Jul 15, 2016, 9:00:05 AM7/15/16
to
On 2016-07-15 11:54 +0200, to...@tuxteam.de wrote:

> As your includes are written above, the C compiler would look
> for a file md5.h in the current compilation directory: most
> probably there isn't one, since whatever package you installed
> will put it in a standard system location, typically under
> /usr/include.

On 2016-07-15 12:56 +0300, Reco wrote:

> #include with encased in 'less' and 'more' characters instructs
> preprocessor to search header files system-wide. A search path can be
> modified with -L flag.
>
> #include with quotes instructs preprocessor to search a header file in
> the current directory.
>
> So probably you meant to write this:
>
> #include <md5.h>

to...@tuxteam.de & Reco's statements could give the impression
that #include <*> searches the standard system include
directories (/usr/include et al.) while #include "*" searches
the current working directory. That's misleading in that
#include "*" also searches the directories that #include <*>
does.

The standard explicitly says so (see [#3] in 6.10.2 in n869, for
instance).

So trying to make cpp find a header by replacing the "" by <> is
not likely to work.

The rule of thumb of using "" for application headers and <> for
system headers is valid. But a more accurate way to summarise
the difference would be that #include <> only looks at the
system directories.

--
André Majorel <http://www.teaser.fr/~amajorel/>
lists.debian.org, a spammer's favourite.

to...@tuxteam.de

unread,
Jul 15, 2016, 9:30:05 AM7/15/16
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Jul 15, 2016 at 02:59:12PM +0200, Andre Majorel wrote:
> On 2016-07-15 11:54 +0200, to...@tuxteam.de wrote:
>
> > As your includes are written above, the C compiler would look
> > for a file md5.h in the current compilation directory: most
> > probably there isn't one, since whatever package you installed
> > will put it in a standard system location, typically under
> > /usr/include.
>
> On 2016-07-15 12:56 +0300, Reco wrote:
>
> > #include with encased in 'less' and 'more' characters instructs
> > preprocessor to search header files system-wide. A search path can be
> > modified with -L flag.
> >
> > #include with quotes instructs preprocessor to search a header file in
> > the current directory.
> >
> > So probably you meant to write this:
> >
> > #include <md5.h>
>
> to...@tuxteam.de & Reco's statements could give the impression
> that #include <*> searches the standard system include
> directories (/usr/include et al.) while #include "*" searches
> the current working directory. That's misleading in that
> #include "*" also searches the directories that #include <*>
> does.
>
> The standard explicitly says so (see [#3] in 6.10.2 in n869, for
> instance).

Yep, you are right.

> So trying to make cpp find a header by replacing the "" by <> is
> not likely to work.

ack.

> The rule of thumb of using "" for application headers and <> for
> system headers is valid. But a more accurate way to summarise
> the difference would be that #include <> only looks at the
> system directories.

again, ack.

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAleI5GgACgkQBcgs9XrR2kZwIgCfWCXUwPjnXNY7DrHp+Nh2RA1j
UWwAnA4yi7K9rj8qZZf1EmMOyjuV4WaF
=y7ea
-----END PGP SIGNATURE-----

Jonathan Dowland

unread,
Jul 15, 2016, 9:50:06 AM7/15/16
to
Do not CC me, I am subscribed to the list. This is clear in the CoC
for lists.debian.org, and it's prominently in the mail signature of
my mail you replied to.

On Fri, Jul 15, 2016 at 12:36:46PM +0200, Nicolas George wrote:
> L'octidi 28 messidor, an CCXXIV, Jonathan Dowland a écrit :
> > FWIW, last time I wanted to do md5 in C, I copied the code into my own
> > project. I got it from the source to dpkg, which did the same thing.
>
> By doing that, you are depriving yourself of future bugfixes and
> improvements to that implementation. Well, MD5 is pretty much set in stone
> and can be completely tested, so it is not a serious concern, but I wanted
> to underline it for the record.

Can't miss an opportunity to go all Comic-Book-Guy on your audience!

There's obviously a trade-off between re-use a library and cargo-cult some code
when implementing something. MD5 is small and simple enough that it falls on
the former side of that line a lot of the time, especially if the alternative
is including a heavy weight library dependency like OpenSSL. One's mileage may
vary depending on the nature of one's particular project.

If it was good enough for dpkg...
signature.asc

Jonathan Dowland

unread,
Jul 15, 2016, 10:00:04 AM7/15/16
to
On Fri, Jul 15, 2016 at 02:59:12PM +0200, Andre Majorel wrote:
> The rule of thumb of using "" for application headers and <> for
> system headers is valid. But a more accurate way to summarise
> the difference would be that #include <> only looks at the
> system directories.

Interesting nuance, thanks!

I wonder if this is why SDL recommends people just use "" for their
own headers.
signature.asc

Nicolas George

unread,
Jul 15, 2016, 11:10:03 AM7/15/16
to
L'octidi 28 messidor, an CCXXIV, Jonathan Dowland a écrit :
> Do not CC me, I am subscribed to the list. This is clear in the CoC
> for lists.debian.org,

Not CCing this once. I recently explained in great length why this point of
the CoC is broken and should be ignored.

> and it's prominently in the mail signature of
> my mail you replied to.

The correct place for that is the message header, not the signature.
Signatures are cosmetic, nobody reads them, the message header is meant to
control the operations.

> Can't miss an opportunity to go all Comic-Book-Guy on your audience!

I have no idea what that means.

> There's obviously a trade-off between re-use a library and cargo-cult some code
> when implementing something. MD5 is small and simple enough that it falls on
> the former side of that line a lot of the time, especially if the alternative
> is including a heavy weight library dependency like OpenSSL. One's mileage may
> vary depending on the nature of one's particular project.
>
> If it was good enough for dpkg...

Too bad you snipped the other paragraph, which was the important part of my
message. Especially the part about the 30% speed difference.

Regards,

--
Nicolas George
signature.asc

Nicolas George

unread,
Jul 15, 2016, 11:30:04 AM7/15/16
to
L'octidi 28 messidor, an CCXXIV, Jonathan Dowland a écrit :
> Interesting nuance, thanks!
>
> I wonder if this is why SDL recommends people just use "" for their
> own headers.

The best explanation I can come up with is that their examples where
originally designed as test programs within the source tree. In that case,
the double quote form is not incorrect. Then they forgot to update it when
turning it into examples and documentation.

The <> / "" distinction is always in a grey area when a project is
constructed as a library plus programs using it. My rule of thumb would be
to use "" for tests programs within the library and <> for examples meant
for outside developers using the library. In fact, the example should be
written to work with the library fully installed and the build tree purged,
although they should include Makefile magic to work directly from the build
tree too.

I think that having "" fall back to searching the system headers like <>
does is a bad design decision and encourages sloppy practices. Of course, it
is way too late to fix that now. #include "stdio.h" should be as much an
error as #include <my_project.h>.

Regards,

--
Nicolas George
signature.asc
0 new messages