This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Linking Error with str_to_str

1

I've made a custom dissector plugin for Wireshark and have a weird linking error. This is my first plugin and am using MSVC 2010 express as my compiler.

I get a linking error that it can't resolve the str_to_str function in value_string.h. It states "unresolved external symbol _str_to_str referenced in function xyz". I'm using value_string and string_string structs and have no problem compiling and linking other functions in the header (such as val_to_str).

any thoughts or ideas why only some things in the header get linked?

BTW also had this happen with the tvb_get_bits from tvbuff.h as well...

asked 06 Oct '11, 13:04

redraymon's gravatar image

redraymon
21115
accept rate: 0%

edited 06 Oct '11, 13:05

Does the error remain if you use MSVC2008 (EE is fine) in stead? Last I checked, 2008 is still the Windows toolchain used for official builds.

(06 Oct '11, 13:12) multipleinte...

Haven't tried with 2008. Don't have a copy and haven't looked for it. If it hinders me then I may try that road but I've built the dissector and essentially have worked around these two functions.

Just found it odd that it would not recognize one function but would be fine with other functions in the same header.

(06 Oct '11, 13:16) redraymon

Are you building your dissector as part of the core Wireshark or a plugin? If you are building it as a plugin, have you compiled Wireshark at least once? Furthermore, are you sure that you are compiling using the correct CRT? MSVC2010 defaults to v100, but official versions of Wireshark (e.g. from the Downloads page) currently uses v90.

(06 Oct '11, 13:53) multipleinte...

Building it as a plugin. I'm using v100 and everything compiles and runs correctly, unless I try to use this one function.

I know that it isn't the same CRT but I'm unsure of why certain functions from a header file would link when one or two don't.

(07 Oct '11, 06:16) redraymon

One Answer:

2

The symbol needs to be exported from libwireshark. Edit epan\libwireshark.def and add an entry for str_to_str.

answered 07 Oct '11, 01:05

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

edited 07 Oct '11, 01:16

I'll give this a try and see what I find out.

(07 Oct '11, 06:16) redraymon

Add the function to the libwireshark.def file and recompiled wireshark. Recompiled my plugin with no issues but trying to run the release version with it fails.

Seems that the official release wasn't compiled with this function either... should this be suggested as a bug? New to this, how is that done?

(07 Oct '11, 06:40) redraymon

Normally opening a bug on https://bugs.wireshark.org is the way to go, but I just committed the change in rev 39304 so there's no need.

BTW, tvb_get_bits is already exported in trunk.

I scheduled both 39304 (str_to_str) and 38301 (tvb_get_bits) to be backported to 1.6.3.

(07 Oct '11, 07:00) JeffMorriss ♦

If the answer is good, please mark it as so by checking it.

(07 Oct '11, 07:07) grahamb ♦

Thanks for the help!

(07 Oct '11, 11:21) redraymon