To get access to a method called:
- Code: Select all
bool GetResourceDir(std::string& dir);
I need this method so that i can get the bundle path to load my bundled plugins.
However my build fails saying: ld: symbol(s) not found for architecture x86_64
I can see that resource_util.h contains some flag "IFDEF POSIX", I am on a mac so i guess that should work, removing this does not seem to impact the problem:
- Code: Select all
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_RESOURCE_UTIL_H_
#define CEF_TESTS_CEFCLIENT_BROWSER_RESOURCE_UTIL_H_
#pragma once
#include <string>
#include "include/cef_stream.h"
namespace client {
#if defined(OS_POSIX)
// Returns the directory containing resource files.
bool GetResourceDir(std::string& dir);
#endif
// Retrieve a resource as a string.
bool LoadBinaryResource(const char* resource_name, std::string& resource_data);
// Retrieve a resource as a steam reader.
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name);
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_BROWSER_RESOURCE_UTIL_H_
The folder contains both: resource_util_mac.mm as well as resource_util_posix.cc. In resource_util_posix the method is used as well, without the compiler complaining:
- Code: Select all
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
std::string path;
if (!GetResourceDir(path)) //<------
return NULL;
path.append("/");
path.append(resource_name);
if (!FileExists(path.c_str()))
return NULL;
return CefStreamReader::CreateForFile(path);
}
} // namespace client
This method is being called from test_runner.cc
- Code: Select all
CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
std::string url = request->GetURL();
if (url.find(kTestOrigin) == 0) {
// Handle URLs in the test origin.
std::string file_name, mime_type;
if (ParseTestUrl(url, &file_name, &mime_type)) {
if (file_name == "request.html") {
// Show the request contents.
const std::string& dump = DumpRequestContents(request);
std::string str = "<html><body bgcolor=\"white\"><pre>" + dump +
"</pre></body></html>";
CefRefPtr<CefStreamReader> stream =
CefStreamReader::CreateForData(
static_cast<void*>(const_cast<char*>(str.c_str())),
str.size());
DCHECK(stream.get());
return new CefStreamResourceHandler("text/html", stream);
} else {
// Load the resource from file.
CefRefPtr<CefStreamReader> stream =
GetBinaryResourceReader(file_name.c_str());
if (stream.get())
return new CefStreamResourceHandler(mime_type, stream);
}
}
}
return NULL;
}
How come the GetResourceDir being accessible/importable from test_runner but not client_app?
My initial problem being:
How can i GetResourceDir from client_app?