Compiling with "name-dev" vs "name" on Linux

I know this falls mostly into a more general question, but I've just discovered this is a thing and wanted to ask how should a Rust program handle it.

Should apps use "name" and libraries "app-dev"? What's the difference between the two? Assuming I wrongly compile one of the above with the dependencies of the other case, is there any difference I should be aware of?

I have never heard of any rust crates using -dev in the name. Are you talking about linux packages? For those libfoo-dev contains a symlink necessary to link against the foo library, while libfoo contains the actual library. You only need libfoo when running a program that uses foo, but you need libfoo-dev during development to compile programs using the foo library.

To elaborate on why libfoo-dev is necessary for linking against foo. This is related to how versioning of libraries is handled. Say the library is version 1.7.0, then there will be a library and a symlink from both and to and are provided by the libfoo package, while is provided by the libfoo-dev package. The linker will only look for, but which it symlinks to contains an instruction to tell the linker that should be referenced in the linked executable instead of This ensures that the executable will always use the right version of the library even if multiple versions of the library are installed.

That was it, should've made it clearer. Thank you!

Mostly mean it for what should be downloaded on a machine you want to compile the program on, since you usually can get both via for example apt install (lib/lib-dev)

Usually -dev packages on linux style systems contain header files. ( the stuff in /usr/include) these are needed by the c compiler to compile and link to libraries. Rust does things differently. You call your "libraries" a crate and they do not have "header" *.h files.

For example..

1 Like

To answer that question, what should be downloaded.

Cargo.toml is a file and in it you put a line under the dependencies section. This line will have the name of the crate (library) and a reference to tell cargo where to get the sources from.

Rust does things differently. You call your "libraries" a crate and they do not have "header" *.h files.

There's still some libraries that need to be downloaded for my program to compile, since I assume some of my dependencies usa a C backend, hence the question.

Yes, if your thing needs c libraries then you will need the libwhatever package and the libwhatever-dev package.
There is some differences in how "c" does things and I might get corrected if I am wrong....I think with c you can link dynamically and then when you give out your program the user will need the libwhatever package on their system. With rust you do not get that dynamic link and your the libwhatever stuff that your program needs gets included in your binary and the end user will not need the libwhatever package.

On debian style systems a good starting point is apt install build-essential

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.